The registry has 40,000 images and storage costs are rising.
IntermediateScenarioMulti-stage builds, cache, tags and registries
Answer
Situation read → No retention policy, SHA tags per commit.
What I'd do →
- Define policy: keep last N tags per branch, keep all release tags, expire untagged after 14 days (ECR lifecycle policy, Harbor retention, GCR cleanup policies).
- Run garbage collection (
registry garbage-collectfor self-hosted). - Dedupe by promoting only release candidates to long-lived repos.
Why → Layers are shared, so deletes only free blobs no manifest references.
Interview tip → Test policies in dry-run mode first.
More on Multi-stage builds, cache, tags and registries
Show a multi-stage Dockerfile for a Java Spring Boot app and explain what you gain.BeginnerCI rebuilds from scratch every run and takes 12 minutes. How do you bring it down?IntermediateYou tag every build `myapp:latest`. A rollback is requested. What happens?BeginnerHow do you promote an image from dev to prod registry without rebuilding?IntermediateDisk on the build server keeps filling up with images.BeginnerWhen do you use `--no-cache` and when is it a smell?Beginner