Docker local Registry


This is to create a Docker local Registry - local meaning creating a Registry in your Server where you have installed Docker.Registry itself is a Container, so you have to pull that using the below command and it will start running when you give this below single command."run" will actually "Pull" the docker image and "start" it so it combines both pull and start command both.


[root@localhost ~]# docker run -d -p 5000:5000 --restart=always --name registry registry:2
16d5c9185c698929a1bc93c2763edf72ae64e403536863199c899ef52e7b8442
[root@localhost ~]# docker images
REPOSITORY                    TAG                 IMAGE ID            CREATED             SIZE
registry                      2                   c2a449c9f834        12 days ago         33.2MB
mysql                         latest              44a8e1a5c0b2        2 weeks ago         407MB
mysql                         testv1              44a8e1a5c0b2        2 weeks ago         407MB
vanithav/mysql1               testv32             44a8e1a5c0b2        2 weeks ago         407MB
vanithav/mysql                testv2              44a8e1a5c0b2        2 weeks ago         407MB
vanithav/soldat/mysql1        testv32             44a8e1a5c0b2        2 weeks ago         407MB
vanithav/soldat/mysql3        testv32             44a8e1a5c0b2        2 weeks ago         407MB
ubuntu                        latest              d355ed3537e9        2 weeks ago         119MB
localhost:5000/myfirstimage   latest              d355ed3537e9        2 weeks ago         119MB
busybox                       latest              c30178c5239f        3 weeks ago         1.11MB
dockercloud/client            latest              a073d03b69b4        4 weeks ago         15.4MB
[root@localhost ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                     PORTS                    NAMES
16d5c9185c69        registry:2          "/entrypoint.sh /e..."   29 seconds ago      Up 23 seconds              0.0.0.0:5000->5000/tcp   registry
ae0f03effd02        busybox             "sh"                     3 hours ago         Exited (130) 2 hours ago                            gallant_yalow
dc1934cbc2cb        d355ed3537e9        "/bin/bash"              3 hours ago         Exited (0) 3 hours ago                              vigorous_shannon
[root@localhost ~]# docker push localhost:5000/myfirstimage      (myfirstimage is a tag I have given for a pulled image called ubuntu)
The push refers to a repository [localhost:5000/myfirstimage]
0566c118947e: Pushed
6f9cf951edf5: Pushed
182d2a55830d: Pushed
5a4c2c9a24fc: Pushed
cb11ba605400: Pushed
latest: digest: sha256:997ed3ab854041884fccb0751ca289b0ae34c9c6d08452aa0d7ce0c69f120769 size: 1357
[root@localhost ~]#

working with Docker Repository using Docker Hub

Bit of cleanup before we start our exercise

How to remove the "exited" containers..

[root@localhost ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                        PORTS                    NAMES
d6ea75809548        ubuntu              "/usr/bin/top -b"        6 minutes ago       Exited (0) 5 minutes ago                               topdemo
6d9128abfa0e        ubuntu              "/bin/bash"              12 minutes ago      Exited (127) 9 minutes ago                             eloquent_wright
e6160af79c48        ubuntu              "/bin/bash"              13 minutes ago      Exited (0) 5 seconds ago                               blissful_gates
cfc0231a0fc2        ubuntu              "/bin/bash"              14 minutes ago      Exited (0) 14 minutes ago                              amazing_bardeen
0c57d7f80eb6        registry:2          "/entrypoint.sh /e..."   2 days ago          Exited (255) 16 minutes ago   0.0.0.0:5000->5000/tcp   registry



root@localhost ~]# docker rm $(docker ps -a -q)
d6ea75809548
6d9128abfa0e
e6160af79c48
cfc0231a0fc2
0c57d7f80eb6
[root@localhost ~]#
------------------------------------------------------------------------------------------------------------
Docker registry is a service that is storing your docker images.
Docker registry could be hosted by a third party, as public or private registry, like one of the following registries:
or you can host the docker registry by yourself
(see https://docs.docker.com/docker-trusted-registry/ for more details).
Docker repository is a collection of different docker images with same name, that have different tags. Tag is alphanumeric identifier of the image within a repository.
For example see https://hub.docker.com/r/library/python/tags/. There are many different tags for the official python image, these tags are all members of the official python repository on the Docker Hub. Docker Hub is a Docker Registry hosted by Docker.
To find out more read:

In the below example I am pulling new image "mysql" from docker hub (public) and "tag"ing that image and pushing back to "my own" docker Hub Registry. I have created an account with docker hub - docker.io/vanithav 

[root@localhost ~]# docker pull mysql
Using default tag: latest
latest: Pulling from library/mysql
9f0706ba7422: Pull complete 
2290e155d2d0: Pull complete 
547981b8269f: Pull complete 
2c9d42ed2f48: Pull complete 
55e3122f1297: Pull complete 
abc10bd84060: Pull complete 
c0a5ce64f2b0: Pull complete 
c4595eab8e90: Pull complete 
098988cead35: Pull complete 
300ca5fa5eea: Pull complete 
43fdc4e3e690: Pull complete 
Digest: sha256:d178dffba8d81afedc251498e227607934636e06228ac63d58b72f9e9ec271a6@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@
Status: Downloaded newer image for mysql:latest   (here latest is the default "tag)
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
ae0f03effd02        busybox             "sh"                9 minutes ago       Up 7 minutes                                    gallant_yalow
dc1934cbc2cb        d355ed3537e9        "/bin/bash"         13 minutes ago      Exited (0) 10 minutes ago                       vigorous_shannon
[root@localhost ~]# docker images
REPOSITORY                    TAG                 IMAGE ID            CREATED             SIZE
registry                      2                   c2a449c9f834        12 days ago         33.2MB
mysql                         latest              44a8e1a5c0b2        2 weeks ago         407MB
ubuntu                        latest              d355ed3537e9        2 weeks ago         119MB
localhost:5000/myfirstimage   latest              d355ed3537e9        2 weeks ago         119MB
busybox                       latest              c30178c5239f        3 weeks ago         1.11MB
dockercloud/client            latest              a073d03b69b4        4 weeks ago         15.4MB

[root@localhost ~]# docker push mysql
The push refers to a repository [docker.io/library/mysql]
6d4c582fc108: Layer already exists 
80f212864222: Layer already exists 
452ca6783f12: Layer already exists 
3c0fa4b13146: Layer already exists 
dd133d6fa27b: Layer already exists 
ebe780cbbabb: Layer already exists 
d18915718e29: Layer already exists 
1324d65ff710: Layer already exists 
9b5e4968c151: Layer already exists 
194d93de739d: Layer already exists 
0d960f1d4fba: Layer already exists 
errors:
denied: requested access to the resource is denied
unauthorized: authentication required  ( this is because I am trying to push to the Docker's public registry where I dont have access)

[root@localhost ~]# docker images
REPOSITORY                    TAG                 IMAGE ID            CREATED             SIZE
registry                      2                   c2a449c9f834        12 days ago         33.2MB
mysql                         latest              44a8e1a5c0b2        2 weeks ago         407MB
ubuntu                        latest              d355ed3537e9        2 weeks ago         119MB
localhost:5000/myfirstimage   latest              d355ed3537e9        2 weeks ago         119MB
busybox                       latest              c30178c5239f        3 weeks ago         1.11MB

First need to login to our own docker hub Registry:

[root@localhost ~]# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username (vanithav): vanithav
Password: 
Login Succeeded

[root@localhost ~]# docker tag mysql:latest vanithav/mysql1:testv32    (I am pushing to my own docker hub with user vanithav and a sub directory called mysql1 - testv32 is the "tag" i have given..)

[root@localhost ~]# docker push vanithav/mysql1:testv32
The push refers to a repository [docker.io/vanithav/mysql1]
6d4c582fc108: Pushed 
80f212864222: Pushed 
452ca6783f12: Pushed 
3c0fa4b13146: Pushed 
dd133d6fa27b: Pushed 
ebe780cbbabb: Pushed 
d18915718e29: Pushed 
1324d65ff710: Pushed 
9b5e4968c151: Pushed 
194d93de739d: Pushed 
0d960f1d4fba: Pushed 
testv32: digest: sha256:793259d9ab1205b94865eb1bc3c6a9451c6d798f3e14d9f16cdfa109478c87a9 size: 2617
[root@localhost ~]# 

Please practice the push/ pull many times, so that you get used to it, otherwise this is a bit confusing.
For experienced people who worked on Unix from a long time this can be compared to a FTP repository, where we do ftp pull and push.


Installing Ingress Controller - Kubernetes

Installing the Ingress Controller Prerequisites Make sure you have access to the Ingress controller image: For NGINX Ingress controll...