You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Building images locally is just the beginning. To share, deploy, and version your images, you need to understand registries, tagging strategies, and image lifecycle management. This lesson covers Docker Hub, private registries, tagging, pushing/pulling, image inspection, and housekeeping.
A container registry is a storage and distribution service for container images. It works like a package repository (npm, PyPI) but for Docker images.
+------------------+ push +------------------+
| Developer | ----------------> | Registry |
| (docker push) | | (Docker Hub, |
+------------------+ pull | ECR, GCR, |
| CI/CD Server | <---------------- | GHCR, etc.) |
| (docker pull) | +------------------+
+------------------+
| Registry | Provider | URL |
|---|---|---|
| Docker Hub | Docker | hub.docker.com |
| GitHub Container Registry (GHCR) | GitHub | ghcr.io |
| Amazon ECR | AWS | *.dkr.ecr.region.amazonaws.com |
| Google Artifact Registry | *.pkg.dev | |
| Azure Container Registry | Microsoft | *.azurecr.io |
| GitLab Container Registry | GitLab | registry.gitlab.com |
Docker Hub is the default registry. When you run docker pull nginx, Docker pulls from Docker Hub.
# Interactive login
docker login
# Login to a specific registry
docker login ghcr.io
docker login 123456789012.dkr.ecr.eu-west-1.amazonaws.com
registry/namespace/repository:tag
# Docker Hub (registry is implicit)
nginx:1.25-alpine # Official image
myuser/my-app:1.0 # User image
# GitHub Container Registry
ghcr.io/myorg/my-app:latest
# Amazon ECR
123456789012.dkr.ecr.eu-west-1.amazonaws.com/my-app:v2.1
Tags are labels attached to image digests. A good tagging strategy is crucial for reliable deployments.
docker build -t my-app:1.0.0 .
docker tag my-app:1.0.0 my-app:1.0
docker tag my-app:1.0.0 my-app:1
docker tag my-app:1.0.0 my-app:latest
This creates a hierarchy:
1.0.0 — exact version (immutable)1.0 — latest patch within 1.0.x1 — latest minor within 1.x.xlatest — most recent release# Tag with the short git commit SHA
docker build -t my-app:$(git rev-parse --short HEAD) .
docker build -t my-app:$(date +%Y%m%d-%H%M%S) .
# e.g. my-app:20260305-143022
| Tag | Purpose | Mutable? |
|---|---|---|
v1.2.3 | Exact release version | No |
abc1234 | Git commit SHA | No |
latest | Most recent build | Yes |
main | Latest build from main branch | Yes |
Best practice: Use immutable tags (semver + SHA) for production. Use
latestonly for development convenience.
# Tag the image with your Docker Hub username
docker tag my-app:1.0.0 myuser/my-app:1.0.0
# Push to Docker Hub
docker push myuser/my-app:1.0.0
# Push all tags for a repository
docker push myuser/my-app --all-tags
# Login to GHCR
echo \$GITHUB_TOKEN | docker login ghcr.io -u USERNAME --password-stdin
# Tag and push
docker tag my-app:1.0.0 ghcr.io/myorg/my-app:1.0.0
docker push ghcr.io/myorg/my-app:1.0.0
# Pull latest
docker pull myuser/my-app
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.