Interview Prep/Docker/Multi-stage builds, cache, tags and registries

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 →

  1. 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).
  2. Run garbage collection (registry garbage-collect for self-hosted).
  3. 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.

All Docker questions Roadmap: Docker & containers

More on Multi-stage builds, cache, tags and registries