What is Docker Registry?
A Docker registry is a system for storing and distributing Docker images with specific names. There may be several versions of the same image, each with its own set of tags. A Docker registry is separated into Docker repositories, each of which holds all image modifications. The registry may be used by Docker users to fetch images locally and to push new images to the registry (given adequate access permissions when applicable). The registry is a server-side application that stores and distributes Docker images. It is stateless and extremely scalable.
The registry usually listens on port 5000 for the instructions like pushing an image, pulling an image, or loading an image from the disc. It maintains an index and search tags and also authorizes and sometimes authenticates connections.
Commands Related to Docker Registry:
1. Starting your registry:
docker run -d -p 5000:5000 --restart=always --name registry registry:2
It instructs Docker to start a registry named registry:2 in detached mode with the name registry. Map the registry’s port 5000 to a local port 5000 and restart it immediately if it dies.
2. Pulling some images from the hub:
docker pull ubuntu:latest
It says docker to pull ubuntu latest.
3. Tagging that image and point to your registry:
docker image tag ubuntu:latest localhost:5000/gfg-image
4. Pushing the image:
docker push localhost:5000/gfg-image
5. Pulling that image back:
docker pull localhost:5000/gfg-image
6. Stop the registry:
docker container stop registry
7. Stop the registry and remove the data:
docker container stop registry && docker container rm -v registry
Why do we use Docker Registry?
Docker registry is an excellent way to supplement and integrate your CI/CD pipelines. Whenever there is a new commit in your source code or version control system, the CI workflow is triggered which then deploys the image to your registry if the CI workflow completion was successful. A signal from the Registry would then initiate a staging environment deployment or alert other systems to the availability of a new image.
So essentially we can say:
- Docker Registry aids in development automation. The docker registry allows you to automate building, testing, and deployment. Docker registry may be used to create faster CI/CD pipelines, which helps to reduce build and deployment time.
- Docker Registry is useful if you want complete control over where your images are kept. A private Docker registry can be used. You gain total control over your applications by doing so. In addition to controlling who may access your Docker images, you can determine who can view them.
- Docker Registry can provide you with information about any issue you may encounter. You may also completely rely on it for container deployment and access it at any moment.
Alternates of Docker Registry:
Following are some of the alternatives of Docker Registry:
- Docker Hub provides users with a free hosted Registry with capabilities of automated build and organization of accounts.
- Few other alternates for Docker Registry are:
- JFrog Bintray i.e a cloud platform that provides services of managing, deploying, and promoting your applications.
- Gitlab Container Registry, which is a private and highly secure repository for storing docker images.