SyntaxStudy
Sign Up
Docker Docker Hub and Private Registries
Docker Beginner 1 min read

Docker Hub and Private Registries

A container registry is a storage and distribution system for Docker images. Docker Hub is the default public registry with millions of official and community images. For production applications, a private registry keeps proprietary images inaccessible to the public and provides access control, vulnerability scanning, and geographic replication. Major cloud providers offer managed registry services: Amazon ECR integrates with IAM roles and ECS/EKS, Google Artifact Registry integrates with GKE and Cloud Build, and Azure Container Registry integrates with AKS. These managed services handle availability, TLS, storage, and replication automatically. For self-hosted needs, Docker's open-source registry:2 image or Harbor provide full control. Image promotion workflows push images to registries at different stages: a CI build pushes to a dev registry after tests pass, the ops team promotes the image to staging, and after acceptance testing it is promoted to the production registry. Using immutable tags (commit SHA or semantic version) rather than latest ensures that each environment runs a precisely known image.
Example
# Amazon ECR authentication
aws ecr get-login-password --region us-east-1 | \
  docker login --username AWS \
  --password-stdin 123456789.dkr.ecr.us-east-1.amazonaws.com

# Tag and push to ECR
docker tag myapp:2.1.0 \
  123456789.dkr.ecr.us-east-1.amazonaws.com/myapp:2.1.0
docker push \
  123456789.dkr.ecr.us-east-1.amazonaws.com/myapp:2.1.0

# Google Artifact Registry
gcloud auth configure-docker us-central1-docker.pkg.dev
docker tag myapp:2.1.0 \
  us-central1-docker.pkg.dev/my-project/my-repo/myapp:2.1.0
docker push \
  us-central1-docker.pkg.dev/my-project/my-repo/myapp:2.1.0

# Self-hosted registry (open-source)
docker run -d \
  --name registry \
  -p 5000:5000 \
  -v registry-data:/var/lib/registry \
  --restart unless-stopped \
  registry:2

docker tag myapp:latest localhost:5000/myapp:latest
docker push localhost:5000/myapp:latest
docker pull localhost:5000/myapp:latest