Docker : Use Docker-Registry2019/05/10 |
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 1dc08e25ca13 registry:2 "/entrypoint.sh /e..." 6 seconds ago Up 4 seconds 0.0.0.0:5000->5000/tcp zealous_beaver |
[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 root_web latest a7b219c76b47 10 minutes ago 709 MB storage latest ea9374e1f84d 34 minutes ago 1.2 MB web_server latest 405d738492e1 40 minutes ago 566 MB srv.world/fedora_httpd latest 3e633f065d3b 46 minutes ago 595 MB docker.io/busybox latest 64f5d945efcc 10 hours ago 1.2 MB docker.io/mariadb latest 1d1a9e0f0e60 13 days ago 381 MB docker.io/fedora latest d09302f77cfc 8 weeks ago 275 MB docker.io/registry 2 f32a97de94e1 2 months ago 25.8 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] 108b1c56d076: Pushed latest: digest: sha256:6fb84ba634fe68572a2ac99741062695db24b921d0aa72e61ee669902f88c187 size: 529[root@dlp ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE root_web latest a7b219c76b47 13 minutes ago 709 MB storage latest ea9374e1f84d 37 minutes ago 1.2 MB web_server latest 405d738492e1 43 minutes ago 566 MB srv.world/fedora_httpd latest 3e633f065d3b 49 minutes ago 595 MB docker.io/busybox latest 64f5d945efcc 10 hours ago 1.2 MB docker.io/mariadb latest 1d1a9e0f0e60 13 days ago 381 MB dlp.srv.world:5000/fedora_reg latest d09302f77cfc 8 weeks ago 275 MB docker.io/fedora latest d09302f77cfc 8 weeks ago 275 MB docker.io/registry 2 f32a97de94e1 2 months ago 25.8 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:787bce7f4d2dafd8c4923dd5c43fb2e4b8473b57ea52f6d12be9bb27bc8f1a85: Pulling from dlp.srv.world:5000/fedora_reg 01eb078129a0: Pull complete Digest: sha256:787bce7f4d2dafd8c4923dd5c43fb2e4b8473b57ea52f6d12be9bb27bc8f1a85 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 d09302f77cfc 8 weeks ago 275 MB |
Sponsored Link |
|