Docker : Use Docker-Registry2018/05/30 |
Install Docker-Registry to build Private Registry for Docker images.
|
|
[1] |
This example is based on the environment that SELnux is Permissive or Disabled.
|
[2] |
On The Host which Docker-Registry Container runs, Get SSL Certificates, refer to here.
This example is based on the case that SSL certificates are gotten under the [/etc/letsencrypt/live/dlp.srv.world] and set the [Common Name] as [dlp.srv.world]. |
[3] | Copy to locate Certificates and pull Registry Image (v2). Container Images are located under [/var/lib/regstry] on Registry v2 Container, so map to mount [/var/lib/docker/registry] on parent Host for Registry Container to use as Persistent Storage |
[root@dlp ~]#
[root@dlp ~]# mkdir /etc/docker/certs.d/dlp.srv.world:5000 [root@dlp ~]# cp -p /etc/letsencrypt/live/dlp.srv.world/cert.pem /etc/docker/certs.d/dlp.srv.world:5000/ca.crt
docker pull registry:2 [root@dlp ~]# mkdir /var/lib/docker/registry [root@dlp ~]# docker run -d -p 5000:5000 \
[root@dlp ~]# -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/fullchain.pem \ -e REGISTRY_HTTP_TLS_KEY=/certs/privkey.pem \ -v /etc/letsencrypt/live/dlp.srv.world:/certs \ -v /var/lib/docker/registry:/var/lib/registry \ registry:2 docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 554520ccf02f registry:2 "/entrypoie..." 8 seconds ago Up 6 seconds 0.0.0.0:5000->5000/tcp quizz... |
[4] | If Firewalld is running, allow mapped port. |
[root@dlp ~]# firewall-cmd --add-port=5000/tcp --permanent success [root@dlp ~]# firewall-cmd --reload success |
[5] | For pushing local Image to Registry Container server, set like follows. |
# list images on Registry container [root@dlp ~]# curl https://dlp.srv.world:5000/v2/_catalog {"repositories":[]} docker images REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/fedora latest cc510acfcd70 3 weeks ago 253 MB docker.io/registry 2 d1fd7d86a825 4 months ago 33.3 MB # set a tag and push [root@dlp ~]# docker tag fedora dlp.srv.world:5000/fedora_reg [root@dlp ~]# docker push dlp.srv.world:5000/fedora_reg The push refers to a repository [dlp.srv.world:5000/fedora_reg] 891e1e4ef82a: Pushed latest: digest: sha256:c4cc32b09c6ae3f1353e7e33a8dda93dc41676b923d6d89afa996b421cc5aa48 size: 529 [root@dlp ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE dlp.srv.world:5000/fedora_reg latest cc510acfcd70 3 weeks ago 253 MB docker.io/fedora latest cc510acfcd70 3 weeks ago 253 MB docker.io/registry 2 d1fd7d86a825 4 months ago 33.3 MB[root@dlp ~]# curl https://dlp.srv.world:5000/v2/_catalog {"repositories":["fedora_reg"]} |
[6] | For getting images from Registry Container server on a Docker node, set like follows. |
# get certificates from Registry Container [root@node01 ~]# mkdir /etc/docker/certs.d/dlp.srv.world:5000 [root@node01 ~]# cd /etc/docker/certs.d/dlp.srv.world:5000 [root@node01 dlp.srv.world:5000]# scp dlp.srv.world:"/etc/docker/certs.d/dlp.srv.world:5000/ca.crt" ./
docker pull dlp.srv.world:5000/fedora_reg Using default tag: latest Trying to pull repository dlp.srv.world:5000/fedora_reg ... sha256:c4cc32b09c6ae3f1353e7e33a8dda93dc41676b923d6d89afa996b421cc5aa48: Pulling from dlp.srv.world:5000/fedora_reg e71c36a80ba9: Pull complete Digest: sha256:c4cc32b09c6ae3f1353e7e33a8dda93dc41676b923d6d89afa996b421cc5aa48 Status: Downloaded newer image for dlp.srv.world:5000/fedora_reg:latest[root@node01 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE dlp.srv.world:5000/fedora_reg latest cc510acfcd70 3 weeks ago 253 MB |
Sponsored Link |