Normally, You will pull an image from Docker Hub, it can be your own images or images from software vendors, open-source projects, and the community.
Now, considering this context, I have a swarm cluster. I will run a custom image of selenium/node-chrome-debug on this cluster. So each time I update the image locally, I need to push it into docker hub under my repository and then pulling the updated image on all nodes in swarm cluster. How long does it takes to pull the updated image for all nodes ? It will depend much on your internet speed.
Using Docker Registry is a solution that helps me save a lot of time to distribute an image across my docker swarm nodes in local environment.
Docker Registry is an open source application that you can run anywhere you please and store your Docker image in. This also allows you to keep them private if you wish or share them as needed .
In my case, I store the new node-chrome-debug image in Docker Registry. When I update new image, I push it into Docker Registry so that other nodes in cluster can easily pull this image instantly.
Docker Registry has the following features:
- Host and manage your own registry, from which you can serve all the repositories as private, public, or a mix between the two
- Scale the registry as needed based on how many images you host or how many pull requests you are serving out
You should use the Registry if you want to:
- Tightly control where your images are being stored
- Fully own your images distribution pipeline
- Integrate image storage and distribution tightly into your in-house development workflow
How to deploy a Docker Registry:
$ docker image pull registry:2
$ docker container run -d -p 5000:5000 --name registry registry:2
Now you have a container running Docker Registry host. Let’s take a quick look at how we can push and pull an image to it. To start off with, we need an image, so let’s grab the ubuntu image.
$ docker pull selenium/node-chrome-debug
Tag the image so that it points to your registry (our localhost IP is 192.168.1.2)
$ docker image tag ubuntu 192.168.1.2:5000/local-node-chrome
Now that we have our image tagged, we can push it to our locally hosted Docker Registry
by running the following command:
$ docker image push 192.168.1.2:5000/local-node-chrome
On any machine in your network , you can pull it back:
$ docker pull 192.168.1.2:5000/local-node-chrome
Now stop your registry and remove all data
$ docker container stop registry && docker container rm -v registry
Reference Link: https://docs.docker.com/registry/