0
0
DockerHow-ToBeginner · 3 min read

How to Push to Private Registry in Docker: Step-by-Step Guide

To push to a private Docker registry, first log in using docker login [registry-url], then tag your image with the registry URL using docker tag, and finally push it with docker push [registry-url]/[repository]/[image-name]:[tag]. This sequence securely uploads your image to your private registry.
📐

Syntax

Here are the main commands to push an image to a private Docker registry:

  • docker login [registry-url]: Authenticate your Docker client to the private registry.
  • docker tag [local-image]:[tag] [registry-url]/[repository]/[image-name]:[tag]: Tag your local image with the private registry address.
  • docker push [registry-url]/[repository]/[image-name]:[tag]: Upload the tagged image to the private registry.
bash
docker login myprivateregistry.com

docker tag myapp:latest myprivateregistry.com/myrepo/myapp:latest

docker push myprivateregistry.com/myrepo/myapp:latest
💻

Example

This example shows how to push a local image named myapp with tag latest to a private registry at myprivateregistry.com under repository myrepo.

bash
docker login myprivateregistry.com

# Output: Login Succeeded

docker tag myapp:latest myprivateregistry.com/myrepo/myapp:latest

docker push myprivateregistry.com/myrepo/myapp:latest

# Output:
# The push refers to repository [myprivateregistry.com/myrepo/myapp]
# 123abc: Pushed
# latest: digest: sha256:abcdef123456 size: 1234
Output
Login Succeeded The push refers to repository [myprivateregistry.com/myrepo/myapp] 123abc: Pushed latest: digest: sha256:abcdef123456 size: 1234
⚠️

Common Pitfalls

Common mistakes when pushing to a private registry include:

  • Not logging in first, causing authentication errors.
  • Forgetting to tag the image with the full registry URL, so Docker tries to push to Docker Hub instead.
  • Using incorrect repository or image names in the tag.
  • Network or firewall blocking access to the private registry.

Always verify your login and tag before pushing.

bash
docker push myapp:latest
# Error: denied: requested access to the resource is denied

# Correct way:
docker login myprivateregistry.com
docker tag myapp:latest myprivateregistry.com/myrepo/myapp:latest
docker push myprivateregistry.com/myrepo/myapp:latest
Output
Error response from daemon: denied: requested access to the resource is denied Login Succeeded The push refers to repository [myprivateregistry.com/myrepo/myapp] 123abc: Pushed latest: digest: sha256:abcdef123456 size: 1234
📊

Quick Reference

CommandPurpose
docker login [registry-url]Authenticate to private registry
docker tag [local-image]:[tag] [registry-url]/[repository]/[image]:[tag]Tag image for private registry
docker push [registry-url]/[repository]/[image]:[tag]Push image to private registry

Key Takeaways

Always log in to your private registry before pushing images using docker login.
Tag your local image with the full private registry URL before pushing.
Use docker push with the tagged image name to upload to the private registry.
Check for authentication errors and correct image tags if push fails.
Ensure network access to your private registry is allowed.