Back to the main page

Local Docker Registry

Docker Registry stores Docker images, and these are read-only templates used to create Docker containers.

Pull Docker's registry container

It's pulled from cloud based Docker registry.
#  docker pull registry 
Using default tag: latest
latest: Pulling from library/registry
3690ec4760f9: Pull complete
930045f1e8fb: Pull complete
feeaa90cbdbc: Pull complete
61f85310d350: Pull complete
b6082c239858: Pull complete
Digest: sha256:1152291c7f93a4ea2ddc95e46d142c31e743b6dd70e194af9e6ebe530f782c17
Status: Downloaded newer image for registry:latest

#  docker images 
REPOSITORY   TAG         IMAGE ID         CREATED             SIZE
registry     latest      c9bd19d022f6     13 days ago         33.27 MB

Start the Local Registry

#  docker run -d -p 5000:5000 --restart=always --name registry registry:2 
Unable to find image 'registry:2' locally
2: Pulling from library/registry
Digest: sha256:1152291c7f93a4ea2ddc95e46d142c31e743b6dd70e194af9e6ebe530f782c17
Status: Downloaded newer image for registry:2
72593902d80944183b52bef4ac7b5f4e0d40958a6456372e645c6381983eba73

Note: use "--restart=always" so the container start after system reboot.

#  docker ps 
CONTAINER ID     IMAGE          COMMAND                  CREATED        STATUS          PORTS                    NAMES
72593902d809     registry:2     "/entrypoint.sh /etc/"   4 seconds ago  Up 3 seconds    0.0.0.0:5000->5000/tcp   registry

Get any image from the hub and tag it to point to Local Registry

#  docker pull oraclelinux && docker tag oraclelinux localhost:5000/oraclelinux  
Using default tag: latest
latest: Pulling from library/oraclelinux
0c333d7e75d2: Pull complete
Digest: sha256:f6cc386e1cc9d6702a67a3be885ddb70a30b0cdafc13d239f5b9ae55f76488ca
Status: Downloaded newer image for oraclelinux:latest

Push it to the Local Registry

#  docker push localhost:5000/oraclelinux  
The push refers to a repository [localhost:5000/oraclelinux]
922b485ea6a7: Pushed
latest: digest: sha256:f6cc386e1cc9d6702a67a3be885ddb70a30b0cdafc13d239f5b9ae55f76488ca size: 529

SSL Certigicate for the Local Registry

Get Certificate and install in, howto depends on your situation, how your company does it.
Here, there are 3 certs, for the host, for the Company (intermediate cert) and root cert (VeriSign).
[root@dockereg_host pki]#  ls -la /pki 
total 32
drwxr-xr-x   2 root root 4096 Jan 24 13:07 .
dr-xr-xr-x. 20 root root 4096 Jan 24 12:31 ..
-rw-rw-r--   1 root root 2474 Jan 24 13:03 dockereg_host_cert.cer
-r--------   1 root root 1704 Jan 24 12:46 dockereg_host_key.pem
-rw-r--r--   1 root root 1074 Jan 24 12:46 dockereg_host_req.pem
-rw-r--r--   1 root root  417 Jan 24 12:45 cert_request.conf
-r--r--r--   1 root root 1860 Jan 24 12:49 Company_SSL_CA.pem
-r--r--r--   1 root root 1760 Jan 24 12:49 Verisign-PublicPrimary.pem

Note: you need all three certs in one file.
[root@dockereg_host pki]#  mv dockereg_host_cert.cer dockereg_host_cert.cer-alone 
[root@dockereg_host pki]#  cat dockereg_host_cert.cer-alone Company_SSL_CA.pem Verisign-PublicPrimary.pem > dockereg_host_cert.cer 

Putting new image to the Local Registry

Pull the image (conserver client) from Docker Hub

#  docker pull zdudic/conserver-client 
Using default tag: latest
latest: Pulling from zdudic/conserver-client
10ec637c060c: Pull complete
1e22e4e97a8f: Pull complete
aaba93d36452: Pull complete
dc3980f40d39: Pull complete
08bb2f35a1d2: Pull complete
Digest: sha256:f77f771f7e2d7717ac89a0b1bf265c8ae39d61c20d6290631ae5e2a2e3cf31a4
Status: Downloaded newer image for zdudic/conserver-client:latest

#  docker images 
REPOSITORY                   TAG                 IMAGE ID            CREATED             SIZE
localhost:5000/oraclelinux   latest              4ee18f43f945        8 days ago          219.4 MB
oraclelinux                  latest              4ee18f43f945        8 days ago          219.4 MB
registry                     2                   c9bd19d022f6        2 weeks ago         33.27 MB
registry                     latest              c9bd19d022f6        2 weeks ago         33.27 MB
zdudic/conserver-client      latest              69474d488cdd        2 weeks ago         294.7 MB
google/cadvisor              latest              cc8254dd08c6        3 weeks ago         47.79 MB

Tag the image to Local Registry, basically this is assigning a new alias to an image in a registry.

#  docker tag zdudic/conserver-client dockereg_host.us.company.com:5000/conserver-client 

#  docker images 
REPOSITORY                                           TAG                 IMAGE ID            CREATED             SIZE
localhost:5000/oraclelinux                           latest              4ee18f43f945        9 days ago          219.4 MB
oraclelinux                                          latest              4ee18f43f945        9 days ago          219.4 MB
registry                                             2                   c9bd19d022f6        2 weeks ago         33.27 MB
registry                                             latest              c9bd19d022f6        2 weeks ago         33.27 MB
dockereg_host.us.oracle.com:5000/conserver-client   latest              69474d488cdd        2 weeks ago         294.7 MB
zdudic/conserver-client                              latest              69474d488cdd        2 weeks ago         294.7 MB
google/cadvisor                                      latest              cc8254dd08c6        3 weeks ago         47.79 MB

Push image to your registry.
#  docker push dockereg_host.company.com:5000/conserver-client 
The push refers to a repository [dockereg_host.console.com:5000/conserver-client]
559d21b66e73: Pushed
b3bfc0182751: Pushed
be0ff80327e9: Pushed
eeeeabaccdcf: Pushed
11327e04fac0: Pushed
latest: digest: sha256:f77f771f7e2d7717ac89a0b1bf265c8ae39d61c20d6290631ae5e2a2e3cf31a4 size: 1369

As verification, from another docker machine get that image:
#  docker pull dockereg_host.company.com:5000/conserver-client 
Using default tag: latest
latest: Pulling from conserver-client
10ec637c060c: Pull complete
1e22e4e97a8f: Pull complete
aaba93d36452: Pull complete
dc3980f40d39: Pull complete
08bb2f35a1d2: Pull complete
Digest: sha256:f77f771f7e2d7717ac89a0b1bf265c8ae39d61c20d6290631ae5e2a2e3cf31a4
Status: Downloaded newer image for dockereg_host.us.oracle.com:5000/conserver-client:latest

Local Docker Registry frontend

Get front end image from from DockerHub.
#  docker pull konradkleine/docker-registry-frontend 
Using default tag: latest
latest: Pulling from konradkleine/docker-registry-frontend
fdd5d7827f33: Pull complete
...
97a0281c7efe: Pull complete
Digest: sha256:1eb28e6d1901b92d90f9deba228e678c45c9fdba9f31c92f597f6692839483dd
Status: Downloaded newer image for konradkleine/docker-registry-frontend:latest

#  docker images 
REPOSITORY                                           TAG                 IMAGE ID            CREATED             SIZE
localhost:5000/oraclelinux                           latest              4ee18f43f945        9 days ago          219.4 MB
oraclelinux                                          latest              4ee18f43f945        9 days ago          219.4 MB
registry                                             2                   c9bd19d022f6        2 weeks ago         33.27 MB
registry                                             latest              c9bd19d022f6        2 weeks ago         33.27 MB
dockereg_host.us.oracle.com:5000/conserver-client   latest              69474d488cdd        2 weeks ago         294.7 MB
zdudic/conserver-client                              latest              69474d488cdd        2 weeks ago         294.7 MB
google/cadvisor                                      latest              cc8254dd08c6        3 weeks ago         47.79 MB
konradkleine/docker-registry-frontend                latest              7621ed3504d4        8 months ago        234.9 MB

Start Local Registry frontend container
#  docker run \
  --restart=always \
  --name docker-registry-frontend \
  -d \
  -e ENV_DOCKER_REGISTRY_HOST=dockereg_host.company.com \
  -e ENV_DOCKER_REGISTRY_PORT=5000 \
  -e ENV_DOCKER_REGISTRY_USE_SSL=1 \
  -e ENV_USE_SSL=yes \
  -v /pki/dockereg_host_cert.cer:/etc/apache2/server.crt:ro \
  -v /pki/dockereg_host_key.pem:/etc/apache2/server.key:ro \
  -p 443:443 \
  konradkleine/docker-registry-frontend:v2 
Note: use "--restart=always" so the container starts after system reboot.

Access via https://dockereg_host.company.com

Sreenshots

Welcome page:



Repositories:





Back to the main page