If you deploy an application inside a container, you may already use a Docker Registry. The Docker Registry provides a simple, secure, and easily extensible way for developers to distribute images and for users to search and download them.
This article will introduce the basic information about Docker Registries and how to create a private Docker Registry.
What is Docker Registry?
Simply, Docker Registry is a tool provided by the Docker project that helps store and distribute containers images. Docker Registry is open source and everyone can download and run for storing your own images.
More broadly, we can understand it as a tool used to store and distribute container images and the Docker project's Docker Registry is a solution, but there are other solutions such as:
- Harbor (an open source option).
- Docker Hub (a solution from Docker).
- JForg Artifactory (a tool to store container images in both on-premises and cloud environments).
- Amazone Elastic Container Registry (a Docker Registry service in the AWS cloud).
- Azure Container Registry (a solution from Azure).
- Google Cloud Container Registry.
How to create a Docker Registry.
When using Docker, people often use container images from Docker Hub.
However, there are some limitations of Docker Hub such as:
- The server is located abroad, so when the international network has problems, downloading container images will take a lot of time.
- Network restrictions for security purposes at some tech companies will also make downloading images from Docker Hub more difficult.
- In some cases, you don't want to make your container images public and the Docker Hub will charge you for the images you host as private. In case you have many percentages of images, the cost is quite a lot of money
With the above information, you can build your own Docker Registry to serve the needs of storing and distributing these container images for project development purposes.
Below are instructions for running a Docker Registry, creating, and pushing a container image to the Docker Registry.
Creating a Docker container from image registry:2
docker run -d -p 5000:5000 --name registry -v C:/Users/pbqtai/docker-registry:/var/lib/registry registry:2
Creating and pushing a container image to the newly created registry.
docker pull php:7.4.33-fpm
Using the below command to perform image tagging.
docker image tag php:7.4.33-fpm localhost:5000/php:7.4.33-fpm
Perform image push to registry server.
docker push localhost:5000/php:7.4.33-fpm
To check whether the container image has been saved in the Docker Registry or not, you can access the url: http://localhost:5000/v2/_catalog
To use this image, type the below command:
docker pull localhost:5000/php:7.4.33-fpm
Now the image will be loaded from the Docker Registry we just created instead of from the Docker Hub.
Hopefully the above information, you can understand more about the Docker Registry and can creating a simple Docker Registry for yourself.
[Reference Source]
- https://appmaster.io/blog/docker-container-overview (Source of images)
- https://hub.docker.com/_/registry
- https://sysdig.com/learn-cloud-native/container-security/what-is-a-docker-registry/