CodeBlanks Logo Icon CodeBlanks

Private registry

Learn to run your own private registry.

A private registry

To run your own registry, the official registry:2 image is enough. Images are tagged with the registry address at the start of the name and pushed:

docker run -d --name registry -p 5000:5000 -v registry-veri:/var/lib/registry registry:2
docker tag api:1.0 localhost:5000/api:1.0
docker push localhost:5000/api:1.0
curl http://localhost:5000/v2/_catalog
# {"repositories":["api"]}

TLS and managed registries

Docker talks to registries other than localhost only over HTTPS. In production a registry is protected with a TLS certificate and authentication; or a managed service is used: GitHub (ghcr.io), GitLab, AWS ECR, Google Artifact Registry, Azure ACR. They all use the same login/tag/push flow.

docker tag api:1.0 registry.sirket.com/ekip/api:1.0
docker login registry.sirket.com
docker push registry.sirket.com/ekip/api:1.0

Practice A local registry

Write three commands: start a container named registry from registry:2 in the background publishing port 5000 with the same number; tag api:1.0 as localhost:5000/api:1.0; push it.

Starter code

terminal
# buraya yaz

Sample solution

terminal
docker run -d --name registry -p 5000:5000 registry:2
docker tag api:1.0 localhost:5000/api:1.0
docker push localhost:5000/api:1.0

Expected output

d6e7f8091a2b
The push refers to repository [localhost:5000/api]
1.0: digest: sha256:4a5b… size: 1789

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 What must the image name be to push it to the registry at localhost:5000?

  • localhost:5000/api:1.0 Correct answer
  • api:1.0@localhost
  • 5000/api:1.0
  • api:localhost:5000

Explanation: If the first part of the name contains a dot or colon, it counts as a registry address.

2 List the repositories in the registry.

Question
curl http://localhost:5000/v2/____
Answer
curl http://localhost:5000/v2/_catalog

Explanation: The catalog endpoint of the Registry HTTP API.

3 Match.

Term Meaning
registry:2 Your own registry
localhost:5000/ Target registry prefix
/v2/_catalog Repository list
ECR, ACR Managed registry

All lessons in Beginner