Your container registry has 80,000 images and the storage bill keeps growing. What's your artifact retention strategy?
BeginnerScenarioPipelines at scale
Answer
Situation read → Most images are PR builds nobody will ever deploy again. Keep releases and what's running, expire the rest.
What I'd do →
- ECR lifecycle policies per repository:
{
"rules": [
{ "rulePriority": 1, "description": "keep releases",
"selection": { "tagStatus": "tagged", "tagPrefixList": ["v"], "countType": "imageCountMoreThan", "countNumber": 50 },
"action": { "type": "expire" } },
{ "rulePriority": 2, "description": "expire untagged",
"selection": { "tagStatus": "untagged", "countType": "sinceImagePushed", "countUnit": "days", "countNumber": 7 },
"action": { "type": "expire" } },
{ "rulePriority": 3, "description": "expire old PR builds",
"selection": { "tagStatus": "any", "countType": "sinceImagePushed", "countUnit": "days", "countNumber": 30 },
"action": { "type": "expire" } }
]
}
- Make sure anything running in production or needed for rollback is protected (release tags with a high count, and deploys by tag that match the keep rule).
- Separate repositories or tag prefixes for dev builds and releases so rules are simple.
Why → Lifecycle rules run automatically; a one-off cleanup grows back in months.
Interview tip → Mention protecting rollback images; deleting the image you need to roll back to is a real incident.
More on Pipelines at scale
The CI pipeline takes 45 minutes. Developers want it under 10. How do you approach it?IntermediateYou have a monorepo with 40 services. Every commit builds and tests all of them. How do you fix that?AdvancedFlaky tests fail 1 in 5 runs and developers just click "re-run". How do you fix this culture and the tests?BeginnerYour self-hosted GitHub runners can't keep up at peak and sit idle at night. How do you run them at scale?AdvancedDocker builds in CI take 12 minutes because every runner starts with an empty cache. How do you speed them up?IntermediateHow do you secure the software supply chain from commit to production?Advanced