Container Registry Best Practices: ECR, Docker Hub, and Self-Hosted Options
Free DevOps Audit Checklist
Get our comprehensive checklist to identify gaps in your infrastructure, security, and deployment processes
Introduction
Container registries are the backbone of containerized application deployment. Choosing the right registry and implementing proper practices can mean the difference between smooth deployments and security nightmares.
Amazon ECR: AWS-Native Registry
# Create a repository
aws ecr create-repository \
--repository-name my-app \
--image-scanning-configuration scanOnPush=true
# Push an image
docker push 123456789012.dkr.ecr.us-east-1.amazonaws.com/my-app:latest
ECR Lifecycle Policies
{
"rules": [{
"rulePriority": 1,
"description": "Keep last 10 production images",
"selection": {
"tagStatus": "tagged",
"tagPrefixList": ["prod-"],
"countType": "imageCountMoreThan",
"countNumber": 10
},
"action": { "type": "expire" }
}]
}
Need DevOps help?
InstaDevOps provides expert DevOps engineering starting at $2,999/mo. Skip the hiring headache.
Book a free 15-min call →Docker Hub
Docker Hub remains the most widely used registry, hosting millions of public images.
Rate Limits: Anonymous pulls limited to 100 per 6 hours; authenticated free users get 200.
Self-Hosted: Harbor
helm install harbor harbor/harbor \
--set expose.type=ingress \
--set expose.ingress.hosts.core=registry.example.com \
--set trivy.enabled=true
Security Best Practices
- Enable image scanning
- Implement least-privilege access
- Sign your images with Cosign
- Use immutable tags
- Scan base images regularly
Image Tagging Strategies
VERSION="1.2.3"
GIT_SHA=$(git rev-parse --short HEAD)
docker build \
-t my-app:${VERSION} \
-t my-app:${VERSION}-${GIT_SHA} \
-t my-app:${GIT_SHA} \
.
Conclusion
Whether you choose ECR for AWS integration, Docker Hub for ubiquity, or Harbor for control, applying security best practices will keep your container infrastructure secure.
Need Help with Your DevOps Infrastructure?
At InstaDevOps, we specialize in helping startups build production-ready infrastructure.
📅 Book a Free 15-Min Consultation
Originally published at instadevops.com
Ready to Transform Your DevOps?
Get started with InstaDevOps and experience world-class DevOps services.
Book a Free CallNever Miss an Update
Get the latest DevOps insights, tutorials, and best practices delivered straight to your inbox. Join 500+ engineers leveling up their DevOps skills.