Skip to content

Docker private registry setup

Docker private registry setup allows for the local hosting and management of Docker images, enabling teams to store and distribute container images within a private infrastructure.^[600-developer__docker__Dockerfile__Dockerfile-01.md]

Deployment

A private registry server can be instantiated using the official registry:2 image.^[600-developer__docker__Dockerfile__Dockerfile-01.md] The service typically runs on port 5000 and requires a mounted volume to persist image data.^[600-developer__docker__Dockerfile__Dockerfile-01.md]

The following command runs the registry in detached mode, mapping the host port 5000 to the container and mounting a local directory for data storage:^[600-developer__docker__Dockerfile__Dockerfile-01.md]

docker run -d \
  -p 5000:5000 \
  -v /path/to/host/dir:/var/lib/registry \
  --name registry \
  registry:2

Client Operations

Pushing Images

To push an image to the private registry, the local image must first be tagged with the registry's address (e.g., 127.0.0.1:5000).^[600-developer__docker__Dockerfile__Dockerfile-01.md]

docker tag mytomcat 127.0.0.1:5000/mytomcat
docker push 127.0.0.1:5000/mytomcat

Pulling Images

Images stored in the private registry can be retrieved using the pull command pointed to the registry's endpoint.^[600-developer__docker__Dockerfile__Dockerfile-01.md]

docker pull 127.0.0.1:5000/mytomcat

API Catalog

The registry provides a HTTP API to query available stored images.^[600-developer__docker__Dockerfile__Dockerfile-01.md] A list of repositories can be retrieved using curl:1

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

Similarly, a list of tags for a specific repository can be viewed:2

curl -X GET http://127.0.0.1:5000/v2/mytomcat/tags/list
# Output example: {"name":"mytomcat","tags":["latest"]}

Web UI

To facilitate easier browsing and management, a web interface can be deployed alongside the registry using tools like hyper/docker-registry-web.34 This container typically links to the main registry container and exposes a UI on port 8080.4

Sources


  1. ^[600-developer__docker__Dockerfile__Dockerfile-01.md#L102-L104] 

  2. ^[600-developer__docker__Dockerfile__Dockerfile-01.md#L108-L109] 

  3. ^[600-developer__docker__Dockerfile__Dockerfile-01.md#L112-L115] 

  4. ^[600-developer__docker__Dockerfile__Dockerfile-01.md#L120-L121]