Interview's MateDocker
Interview's Mate

Docker

Compose · Networking · Security · Ops

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Docker topics
Lesson 124/ 160
07. CI/CD, Registries & Production Operations

Image Retention Policies, Garbage Collection & Vulnerability Gates

Set retention and vulnerability gates so registries stay clean and safe.

IntermediateRetention · GC3 quiz questions
Practice DevOps Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

Align registry deletion with rollback windows, release evidence and signature/SBOM retention.

Think of it like…

Retention is the archive destruction schedule: the label disappears first, but the box remains until every legal hold and cross-reference is released.

Where you’ve seen it

In practice, curl -X DELETE $REGISTRY/v2/acme/api/manifests/$DIGEST; registry garbage-collect --dry-run /etc/docker/registry/config.yml is the concrete move for this job: set retention and vulnerability gates so registries stay clean and safe. The release is not accepted until trace a deployed, signed and rollback-tagged digest through retention roots, then prove an expired unreferenced blob is removed confirms the result.

Words you’ll hear

Retention
The implementation control in curl -X DELETE $REGISTRY/v2/acme/api/manifests/$DIGEST; registry garbage-collect --dry-run /etc/docker/registry/config.yml for set retention and vulnerability gates so registries stay clean and safe.
GC
The result to observe with trace a deployed, signed and rollback-tagged digest through retention roots, then prove an expired unreferenced blob is removed, rather than infer from a successful command alone.
Vuln Gates
The production boundary exposed when deleting every tag older than 7 days when deployment rollback requires 30 days, or a scanner gate that approves a mutable tag instead of a digest.

Visual diagram

Loading interactive diagram

Theory & deep dive

Retention control path

The concrete mechanism is curl -X DELETE $REGISTRY/v2/acme/api/manifests/$DIGEST; registry garbage-collect --dry-run /etc/docker/registry/config.yml. The observable result is trace a deployed, signed and rollback-tagged digest through retention roots, then prove an expired unreferenced blob is removed; if those disagree, inspect the runtime evidence before changing unrelated settings.

Set retention and vulnerability gates so registries stay clean and safe. Keep Retention, GC and Vuln Gates in the same deployment record so the intent and the observed state cannot drift apart.

Concrete Retention setup

curl -X DELETE $REGISTRY/v2/acme/api/manifests/$DIGEST; registry garbage-collect --dry-run /etc/docker/registry/config.yml

Key takeaway: Prove GC with trace a deployed, signed and rollback-tagged digest through retention roots, then prove an expired unreferenced blob is removed, not with command success alone.

Vuln Gates failure boundary

Deleting a tag is not immediate blob deletion, and GC can break old signed references if retention ignores attestations. A gate on severity with no expiry/exception workflow either blocks releases forever or trains teams to bypass it. The narrow failure to design for is deleting every tag older than 7 days when deployment rollback requires 30 days, or a scanner gate that approves a mutable tag instead of a digest.

Accept this compromise explicitly: Aggressive retention reduces cost; longer provenance windows support incident response and rollback at storage expense. The controlled check-trace a deployed, signed and rollback-tagged digest through retention roots, then prove an expired unreferenced blob is removed-also identifies the point where a different design is safer.

Deliberate failure test

Exercise this failure safely: deleting every tag older than 7 days when deployment rollback requires 30 days, or a scanner gate that approves a mutable tag instead of a digest.

Key takeaway: Aggressive retention reduces cost; longer provenance windows support incident response and rollback at storage expense.

How it works, step by step

Step 1 of 4
Design

1. State the boundary

Write down why the workload needs this: Deleting a tag is not immediate blob deletion, and GC can break old signed references if retention ignores attestations. A gate on severity with no expiry/exception workflow either blocks releases forever or trains teams to bypass it.

Align registry deletion with rollback windows, release evidence and signature/SBOM retention.
Key numbers at this step
Intent
Retention

When to use it & trade-offs

What it is

Retention decides which manifests and tags should survive, garbage collection reclaims blobs no longer reachable from retained roots, and vulnerability/provenance gates decide which exact digest may advance. Manifests referenced by a deployment or signature are roots even if human-facing tags are old.

Why it matters: Deleting a tag is not immediate blob deletion, and GC can break old signed references if retention ignores attestations. A gate on severity with no expiry/exception workflow either blocks releases forever or trains teams to bypass it.

When to reach for it

  • The fit is strongest for this job: set retention and vulnerability gates so registries stay clean and safe. Pair it with trace a deployed, signed and rollback-tagged digest through retention roots, then prove an expired unreferenced blob is removed in the runbook.
  • Production Retention changes should make GC observable through curl -X DELETE $REGISTRY/v2/acme/api/manifests/$DIGEST; registry garbage-collect --dry-run /etc/docker/registry/config.yml, rather than trusting the runtime default.
  • Keep a rollback example for the case where deleting every tag older than 7 days when deployment rollback requires 30 days, or a scanner gate that approves a mutable tag instead of a digest.

When to avoid or be careful

  • Do not accept command success while the system can still fail by deleting every tag older than 7 days when deployment rollback requires 30 days, or a scanner gate that approves a mutable tag instead of a digest.
  • Avoid erasing Vuln Gates protection merely to dodge this cost: “Aggressive retention reduces cost; longer provenance windows support incident response and rollback at storage expense”.
  • Do not replace the evidence path-trace a deployed, signed and rollback-tagged digest through retention roots, then prove an expired unreferenced blob is removed-with a screenshot or a mutable tag.

curl -X DELETE $REGISTRY/v2/acme/api/manifests/$DIGEST; registry garbage-collect --dry-run /etc/docker/registry/config.yml: practical choices

Explicit Retention
Best for: Set retention and vulnerability gates so registries stay clean and safe, with a reviewed runbook.

Strengths: Retention decides which manifests and tags should survive, garbage collection reclaims blobs no longer reachable from retained roots, and vulnerability/provenance gates decide which exact digest may advance. Manifests referenced by a deployment or signature are roots even if human-facing tags are old.

Watch out: Aggressive retention reduces cost; longer provenance windows support incident response and rollback at storage expense.

Ambient default
Best for: Short-lived GC experiments with low blast radius.

Strengths: It can begin with curl -X DELETE $REGISTRY/v2/acme/api/manifests/$DIGEST; registry garbage-collect --dry-run /etc/docker/registry/config.yml and fewer surrounding controls.

Watch out: It silently accepts deleting every tag older than 7 days when deployment rollback requires 30 days, or a scanner gate that approves a mutable tag instead of a digest, which makes the result hard to reproduce after promotion.

Managed Vuln Gates
Best for: Teams that centralize Vuln Gates policy across many workloads.

Strengths: Deleting a tag is not immediate blob deletion, and GC can break old signed references if retention ignores attestations. A gate on severity with no expiry/exception workflow either blocks releases forever or trains teams to bypass it.

Watch out: The platform adds an ownership and debugging layer; retain trace a deployed, signed and rollback-tagged digest through retention roots, then prove an expired unreferenced blob is removed as the direct check.

Interview signals & numbers to know

When this topic comes up

  • curl -X DELETE $REGISTRY/v2/acme/api/manifests/$DIGEST; registry garbage-collect --dry-run /etc/docker/registry/config.yml
  • trace a deployed, signed and rollback-tagged digest through retention roots, then prove an expired unreferenced blob is removed
  • Failure signature: deleting every tag older than 7 days when deployment rollback requires 30 days, or a scanner gate that approves a mutable tag instead of a digest
  • Trade-off: Aggressive retention reduces cost; longer provenance windows support incident response and rollback at storage expense.

Benchmarks & rules of thumb

7/30 days -
example release-versus-rollback retention split
1 digest root -
signatures and deployments each need reachability analysis
0 blob space reclaimed -
when GC has not run after tag deletion

Common mistakes & follow-ups

Common interview mistakes

  • Treating a successful curl -X DELETE $REGISTRY/v2/acme/api/manifests/$DIGEST; registry garbage-collect --dry-run /etc/docker/registry/config.yml as proof and skipping trace a deployed, signed and rollback-tagged digest through retention roots, then prove an expired unreferenced blob is removed.
  • Deleting every tag older than 7 days when deployment rollback requires 30 days, or a scanner gate that approves a mutable tag instead of a digest
  • Optimizing Retention without accepting that aggressive retention reduces cost; longer provenance windows support incident response and rollback at storage expense.

Likely interviewer follow-ups

  • Why does curl -X DELETE $REGISTRY/v2/acme/api/manifests/$DIGEST; registry garbage-collect --dry-run /etc/docker/registry/config.yml address Retention here rather than through application code?
  • How would you distinguish healthy GC from the failure “deleting every tag older than 7 days when deployment rollback requires 30 days, or a scanner gate that approves a mutable tag instead of a digest” using trace a deployed, signed and rollback-tagged digest through retention roots, then prove an expired unreferenced blob is removed?
  • When would this trade-off-“Aggressive retention reduces cost; longer provenance windows support incident response and rollback at storage expense”-justify a different Vuln Gates design?
Interview tip: Give one concrete operation-curl -X DELETE $REGISTRY/v2/acme/api/manifests/$DIGEST; registry garbage-collect --dry-run /etc/docker/registry/config.yml-and one proof-trace a deployed, signed and rollback-tagged digest through retention roots, then prove an expired unreferenced blob is removed. Then name the boundary: deleting every tag older than 7 days when deployment rollback requires 30 days, or a scanner gate that approves a mutable tag instead of a digest.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply Image Retention Policies, Garbage Collection & Vulnerability Gates with generative AI interview Q&A and hands-on practice.

Open DevOps Q&A →Tech Learn Q&A
Previous topic
Authenticating, Pushing & Pulling from Private Registries
Next topic
Automated Docker Builds in GitHub Actions