Private Docker Registry with registry:2¶
A Private Docker registry allows users to store and distribute Docker images within a local or controlled network environment, offering an alternative to the public Docker Hub. Using the official registry:2 image provides a standard way to deploy this service via a container^[600-developer__docker__Dockerfile__Dockerfile-01.md].
Deployment¶
To set up the registry server, you can run the official registry:2 image. The service typically listens on port 5000. It is recommended to mount a volume to persist the registry data on the host, preventing data loss if the container is removed^[600-developer__docker__Dockerfile__Dockerfile-01.md].
The following command starts the registry in detached mode, maps port 5000, and mounts a local directory to the container's data storage path^[600-developer__docker__Dockerfile__Dockerfile-01.md]:
docker run -d -p 5000:5000 -v C:/docker.resistry:/var/lib/registry --name registry registry:2
Usage Workflow¶
Pushing Images¶
To push an image to the private registry, you must first tag it with the registry's address and port^[600-developer__docker__Dockerfile__Dockerfile-01.md].
- Tag the image:
docker tag mytomcat 127.0.0.1:5000/mytomcat - Push the image:
docker push 127.0.0.1:5000/mytomcat
Pulling Images¶
Images stored in the private registry can be pulled using the same address format used during the push^[600-developer__docker__Dockerfile__Dockerfile-01.md].
docker pull 127.0.0.1:5000/mytomcat
API & Verification¶
The registry includes an HTTP API that can be used to query available images and tags^[600-developer__docker__Dockerfile__Dockerfile-01.md].
-
List Repositories: To see all stored repositories (images), use the
_catalogendpoint^[600-developer__docker__Dockerfile__Dockerfile-01.md]:Example Output:curl -X GET http://127.0.0.1:5000/v2/_catalog{"repositories":["mytomcat"]}^[600-developer__docker__Dockerfile__Dockerfile-01.md] -
List Tags: To list available tags for a specific repository^[600-developer__docker__Dockerfile__Dockerfile-01.md]:
curl -X GET http://127.0.0.1:5000/v2/mytomcat/tags/list
Related Concepts¶
- Dockerfile: Defines the blueprint for building the images stored in the registry.
- [[Containerization]]: The broader practice of encapsulating applications in containers.
- [[Reverse Engineering]]: Occasionally mentioned in database contexts ER/Studio, but conceptually relates to understanding existing structures.
Sources¶
^[600-developer__docker__Dockerfile__Dockerfile-01.md]