Skip to content
Back to Deployment

Container Registry

Store and distribute Docker images — Docker Hub, ECR, GCR, GHCR, Harbor.

ContainersIntermediate

Why

Container registries store versioned images for deployment. Cloud registries (ECR, GCR) integrate with cloud auth, Harbor adds vulnerability scanning and replication.

Docker is used by 59% of professional developers per the Stack Overflow 2024 survey, and Kubernetes runs 60% of containerized workloads in production (CNCF 2024 survey). Container orchestration reduces deployment-related incidents by 35% through declarative rollouts.

When

Use cloud registry (ECR/GCR/GHCR) for cloud deploys, Harbor for self-hosted with scanning. Avoid Docker Hub for private (rate limits).

How

1. Create — cloud CLI or web console 2. Auth — docker login with token/credentials 3. Tag — docker tag app:latest registry/app:v1 4. Push — docker push registry/app:v1 5. Pull — docker pull registry/app:v1 6. Scan — trivy or registry built-in scan 7. Cleanup — lifecycle policy to delete old

Example

# AWS ECR aws ecr get-login-password | docker login --username AWS --password-stdin $acct.dkr.ecr.us-east-1.amazonaws.com docker tag app:latest $acct.dkr.ecr.us-east-1.amazonaws.com/app:v1 docker push $acct.dkr.ecr.us-east-1.amazonaws.com/app:v1 # GitHub Container Registry echo $GH_TOKEN | docker login ghcr.io -u USERNAME --password-stdin docker tag app:latest ghcr.io/user/app:v1 docker push ghcr.io/user/app:v1 # Scan with trivy trivy image ghcr.io/user/app:v1 # ECR lifecycle policy (delete untagged after 7 days) aws ecr put-lifecycle-policy --repository-name app --policy-text file://policy.json

Common Problems

  • ⚠Docker Hub rate limit — 100 pulls/6h anonymous, use auth or cloud registry
  • ⚠Old images accumulate — no lifecycle policy, set cleanup rules
  • ⚠Configuration drift between environments — use infrastructure-as-code (Terraform/Pulumi) to keep dev/staging/prod identical

Best Practices

  • ✓Use immutable tags (git SHA or semver) — not latest, ensures reproducible deploys
  • ✓Set lifecycle policy — auto-delete old untagged images, save storage cost
  • ✓Set up health checks and graceful shutdown — handle SIGTERM to drain in-flight requests before exit

FAQ