Skip to content

Private Docker Registry

A Private Docker Registry is a storage and distribution system for named Docker images, typically hosted locally or within a private network. It allows teams to share and manage container images without relying solely on public hubs like Docker Hub^[600-developer-docker-dockerfile-dockerfile-01.md].

Deployment

The registry is typically run as a Docker container using the official registry:2 image. To start the service, a command is issued to run the container in detached mode, mapping the host's port 5000 to the container's port 5000^[600-developer-docker-dockerfile-dockerfile-01.md].

It is common practice to mount a volume from the host (e.g., C:/docker.resistry) to the container's data directory (/var/lib/registry). This ensures that image data persists even if the registry container is removed^[600-developer-docker-dockerfile-dockerfile-01.md].

docker run -d -p 5000:5000 -v C:/docker.resistry:/var/lib/registry --name registry registry:2

Image Management

Pushing Images

To store an image in the private registry, it must first be tagged with the registry's address and port^[600-developer-docker-dockerfile-dockerfile-01.md].

  1. Tag the image:
    docker tag mytomcat 127.0.0.1:5000/mytomcat
    
  2. Push the image:
    docker push 127.0.0.1:5000/mytomcat
    

Pulling Images

Images can be retrieved from the private registry using the pull command with the specific registry address^[600-developer-docker-dockerfile-dockerfile-01.md].

docker pull 127.0.0.1:5000/mytomcat

Querying the Catalog

The registry provides an HTTP API to list stored images. A GET request to the /v2/_catalog endpoint returns a list of repositories available in the registry^[600-developer-docker-dockerfile-dockerfile-01.md].

curl -X GET http://127.0.0.1:5000/v2/_catalog
# Output: {"repositories":["mytomcat"]}

Web UI

While the base registry service is accessed via CLI or API, a web interface can be added for easier management. The hyper/docker-registry-web image is often used for this purpose^[600-developer-docker-dockerfile-dockerfile-01.md].

When deploying the web UI, it typically needs to be linked to the main registry container. Environment variables are used to configure the connection, pointing the web UI to the registry's API URL (e.g., http://registry-srv:5000/v2)^[600-developer-docker-dockerfile-dockerfile-01.md].

  • [[Docker]]
  • DevOps
  • [[Containerization]]

Sources