Back to course

Lesson 27: Tagging and Pushing Custom Images to a Registry

Docker Zero to Hero: The Complete Containerization Course for Beginners

Lesson 27: Tagging and Pushing Custom Images to a Registry

Before you can share your custom image with your team or deploy it to a server, you must tag it correctly and push it to a registry.

1. Authentication (Login)

Before pushing, you must log into the target registry. For Docker Hub, this is simple:

bash docker login

Enter your Docker Hub username and password

For cloud registries (ECR, ACR), you usually need to use a specific CLI command provided by the cloud vendor to get a temporary access token.

2. Tagging the Image

We need to retag our locally built image so its name includes the registry path.

Assume you built an image named my-web:latest.

Scenario 1: Pushing to Docker Hub (Your Account)

bash

Syntax: docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]

docker tag my-web:latest myusername/my-web-app:v1.0

Scenario 2: Pushing to a Cloud Registry (e.g., myregistry.io)

bash docker tag my-web:latest myregistry.io/development/web-app:20240101

Verify the new tag is listed locally:

bash docker images

3. Pushing the Image

Once tagged, use the docker push command:

bash

Push to Docker Hub

docker push myusername/my-web-app:v1.0

Push to Cloud Registry

docker push myregistry.io/development/web-app:20240101

Docker will transfer only the layers that are unique to your image. Once pushed, anyone with access to that registry can pull the image and run your containerized application.