Beginner LevelDocker & Deployment
What is a Docker Registry (Docker Hub, ECR) and how do push/pull commands operate?
❓ Interview Prompt: Explain Docker image registries, image tagging conventions, authentication, and push/pull workflows in CI/CD pipelines.
A Docker Registry is a versioned storage and distribution system for Docker images. It is the equivalent of npm for packages — you push images to a registry and pull them onto any machine.
Registry Types:
•
Docker Hub (
hub.docker.com) — default public registry. Free tier with rate limits.•
AWS ECR (Elastic Container Registry) — private managed registry on AWS.
•
GitHub Container Registry (ghcr.io) — integrated with GitHub Actions.
•
Self-hosted (Harbor, GitLab Registry) — on-premises private registries.
Image Naming Convention:
[registry]/[namespace]/[repository]:[tag]
•
nginx:alpine → Docker Hub official image (short form)•
myuser/myapp:v1.2.3 → Docker Hub user image•
123456789.dkr.ecr.us-east-1.amazonaws.com/myapp:latest → AWS ECRTag Conventions:
•
latest — most recent build (avoid in production — not immutable!)•
v1.2.3 — semantic versioning (recommended)•
sha-abc1234 — Git commit SHA (fully reproducible, best for CI/CD)Code Implementation Example
bash
# Authenticate to Docker Hub
docker login -u myusername
# Authenticate to AWS ECR
aws ecr get-login-password --region us-east-1 | \
docker login --username AWS --password-stdin \
123456789.dkr.ecr.us-east-1.amazonaws.com
# Build and tag with multiple tags (semantic + git SHA)
GIT_SHA=$(git rev-parse --short HEAD)
docker build -t myapp:latest -t myapp:v1.2.3 -t myapp:${GIT_SHA} .
# Tag for remote registry
docker tag myapp:v1.2.3 myuser/myapp:v1.2.3
# Push to Docker Hub
docker push myuser/myapp:v1.2.3
docker push myuser/myapp:latest
# Pull on target server
docker pull myuser/myapp:v1.2.3
# List local images
docker images | grep myapp💡Full registry workflow: authenticate, build, tag with semantic version + git SHA, push and pull.
🎯 Interview Key Takeaway
Never use :latest in production — tag images with semantic versions or git SHAs for reproducible deployments. Use ECR/ghcr.io for private images in CI/CD.
#Docker#Registry#Docker Hub#ECR#Image Tagging#Beginner
Back to all Docker & Deployment Questions→