CentOS 7
Sponsored Link

Docker : Use Docker-Registry
2015/12/17
 
Configure Docker Private Registry to push/pull Docker images from self private registry.
[1] Docker image for Registry is provided officially, so it's easy to create your private registry like follows.
On the example below, images are saved under [/var/lib/registry] of the local filesystem.
[root@dlp ~]#
docker run -d -p 5000:5000 -v /var/lib/registry:/var/lib/registry --restart=always --name registry registry:2

Trying to pull repository docker.io/library/registry ...
2: Pulling from docker.io/library/registry
81033e7c1d6a: Pull complete
Status: Downloaded newer image for docker.io/registry:2
5188ec6904756070138edfc49d4c0f231841bfbdd620556a85eb44b201b37b31
[root@dlp ~]#
docker ps

CONTAINER ID  IMAGE      COMMAND                 CREATED     STATUS        PORTS                  NAMES
5188ec690475  registry:2 "/entrypoint.sh /e..."  16 sec ago Up 14 seconds  0.0.0.0:5000->5000/tcp registry
[2] To use private registry from other Docker clients, they try to access with HTTPS by default but the setting of Registry above is not for HTTPS, they cannot access. So it needs to change Docker clients' setting they can access with HTTP connection.
If you'd like to use HTTPS conncection, refer to here.
[root@node01 ~]#
vi /etc/sysconfig/docker
# line 4: add Docker-Registry's URL

OPTIONS='
--insecure-registry dlp.srv.world:5000
--selinux-enabled --log-driver=journald.....'
[root@node01 ~]#
systemctl restart docker
[3] To push or pull from private registry on other Docker clients, do like follows.
[root@node01 ~]#
docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
docker.io/centos    latest              e934aafc2206        9 days ago          199 MB

# set tag and push

[root@node01 ~]#
docker tag centos dlp.srv.world:5000/centos

[root@node01 ~]#
docker push dlp.srv.world:5000/centos

The push refers to a repository [dlp.srv.world:5000/centos]
43e653f84b79: Pushed
latest: digest: sha256:191c883e479a7da2362b2d54c0840b2e8981e5ab62e11ab925abf8808d3d5d44 size: 529
[root@node01 ~]#
docker images

REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
docker.io/centos            latest              e934aafc2206        9 days ago          199 MB
dlp.srv.world:5000/centos   latest              e934aafc2206        9 days ago          199 MB

# delete all images once to verify Pull

[root@node01 ~]#
docker rmi docker.io/centos

[root@node01 ~]#
docker rmi dlp.srv.world:5000/centos

[root@node01 ~]#
docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

[root@node01 ~]#
docker pull dlp.srv.world:5000/centos

Using default tag: latest
Trying to pull repository dlp.srv.world:5000/centos ...
latest: Pulling from dlp.srv.world:5000/centos
469cfcc7a4b3: Pull complete
Digest: sha256:191c883e479a7da2362b2d54c0840b2e8981e5ab62e11ab925abf8808d3d5d44
Status: Downloaded newer image for dlp.srv.world:5000/centos:latest
[root@node01 ~]#
docker images

REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
dlp.srv.world:5000/centos   latest              e934aafc2206        9 days ago          199 MB
Matched Content
 
Tweet