Docker Private Registry - HaymonEdmur/DockerConfiguration GitHub Wiki
Docker Private Registry
Docker registry image on docker hub uses tcp port 5000 and static directory path to manage images. The YAML configuration file in image defines this configuration.
- Download registry image
# docker pull registry
- Create registry container
Dump this container to a tar archive and extract it in /tmp to refer YAML configuration.
# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
registry latest d1fd7d86a825 4 weeks ago 33.3MB
# docker run -d registry
c46b242e4167782ac7f0873720495f4e2b2d86d3a033961d8b712b06f4664f62
# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
NAMES
c46b242e4167 registry "/entrypoint.sh /e..." 8 seconds ago Up 5 seconds 5000/tcp
# docker export c46b242e4167 > /tmp/registry.tar
# ls -l /tmp/registry.tar
-rw-r--r-- 1 root root 35716096 Feb 12 13:17 /tmp/registry.tar
# docker stop c46b242e4167
# docker rm c46b242e4167
# cd /tmp; mkdir REGISTRY; cd REGISTRY; tar xvf ../registry.tar
- Default YAML configuration file
# cat etc/docker/registry/config.yml
version: 0.1
log:
fields:
service: registry
storage:
cache:
blobdescriptor: inmemory
filesystem:
rootdirectory: /var/lib/registry
http:
addr: :5000
headers:
X-Content-Type-Options: [nosniff]
health:
storagedriver:
enabled: true
interval: 10s
threshold: 3
- Customize Image storage directory
# mkdir /var/Private_Registry
# docker run -d -p 5000:5000 -v /var/Private_Registry:/var/lib/registry registry
- Tag and Push Image to the private registry
# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
registry latest d1fd7d86a825 4 weeks ago 33.3MB
alpine latest 3fd9065eaf02 4 weeks ago 4.15MB
# docker tag alpine:latest localhost:5000/alpine:private
# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
registry latest d1fd7d86a825 4 weeks ago 33.3MB
alpine latest 3fd9065eaf02 4 weeks ago 4.15MB
localhost:5000/alpine private 3fd9065eaf02 4 weeks ago 4.15MB
# ls /var/Private_Registry
# docker push localhost:5000/alpine:private
The push refers to a repository [localhost:5000/alpine]
cd7100a72410: Pushed
private: digest: sha256:8c03bb07a531c53ad7d0f6e7041b64d81f99c6e493cb39abba56d956b40eacbc size: 528
# ls /var/Private_Registry/docker/registry/v2/repositories/
alpine
- Pull Image from local private registry
# docker pull localhost:5000/alpine:private
private: Pulling from alpine
ff3a5c916c92: Pull complete
Digest: sha256:8c03bb07a531c53ad7d0f6e7041b64d81f99c6e493cb39abba56d956b40eacbc
Status: Downloaded newer image for localhost:5000/alpine:private
root@UBUNTU16:/tmp/REGISTRY# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
registry latest d1fd7d86a825 4 weeks ago 33.3MB
localhost:5000/alpine private 3fd9065eaf02 4 weeks ago 4.15MB