Chapter 24Lesson 01210–280 min

Docker Registry Operations, Garbage Collection, Retention, Search, Proxying, and Production Troubleshooting: Concepts, Architecture, and Mental Model

Advance from “docker push and pull works” to the operator’s view of a registry: tags are mutable names, digests identify manifest bytes, manifests reference shared layers, cleanup moves through several logical and physical stages, and proxy/search/authentication behavior must be diagnosed independently.

Docker registryTags and digestsShared layersGarbage collectionProxy/cache

Learning objectives

  • Explain tag, manifest, digest, config, layer, manifest-list/index, component, and asset relationships without collapsing them into “an image.”
  • Trace the supported Docker cleanup chain from retention intent through logical deletion, Docker garbage collection, and blob-store compaction.
  • Separate hosted, proxy, and group behavior from Docker client cache, upstream registry state, and reverse-proxy/network state.
  • Explain the limits of Docker search/discovery and the difference between Nexus SQL search, Registry API listing, and Docker client search.
  • Use read-only HTTP/Nexus evidence to diagnose registry state before mutating content.
Version baseline (27 August 2026). The chapter uses Nexus Repository 3.95.2-01 with Java 21 as its dated reference line. Docker behavior has changed substantially across releases; re-check the exact task names, known issues, routing mode, and release notes on the instance you operate.
Current 3.94.0–3.95.2 Docker cleanup warning. Sonatype documents an open issue where Docker manifest HEAD requests do not refresh an asset's lastDownloaded timestamp. An actively used image can therefore look inactive. Do not use Last Downloaded–based Docker cleanup policies on an affected instance until Sonatype publishes a fixed version.
Safety boundary. All destructive steps must target explicitly named disposable repositories and synthetic images. Never delete production tags/manifests, edit blob-store files, remove database rows, disable TLS validation, or run garbage collection/compaction on valuable repositories merely to observe behavior.

1. The operator’s problem: “image size” and “tag count” are misleading

Chapter 8 taught Docker/OCI repository basics. At production scale, the difficult questions are different: Which exact manifest did a tag resolve to? Which layers are shared by ten images? Why did deleting a tag free almost no disk space? Why does a proxy return an older tag than expected? Why does the Docker client report 401, 404, or 429? Which task can safely reclaim unreferenced layers, and which task merely marks repository content as deleted?

The operational mistake is to treat a Docker image as one file. A registry stores a graph of metadata and blobs. Retention and troubleshooting have to follow that graph.

2. Identity hierarchy: reference → tag or digest → manifest → config/layers

flowchart LR
  REF[image reference] --> TAG[tag such as 1.4 or latest]
  REF --> DG[digest reference sha256:...]
  TAG --> MAN[manifest or image index]
  DG --> MAN
  MAN --> CFG[config blob]
  MAN --> L1[layer A]
  MAN --> L2[layer B]
  OTHER[another manifest] --> L1
  OTHER --> L3[layer C]

A tag is a human-friendly alias. It can be moved to point to a different manifest unless your process prevents that. A digest is calculated from manifest content and identifies those manifest bytes. A manifest references a configuration blob and one or more layer blobs. Multiple manifests can reuse the same layer digest, so physical storage is deduplicated within the relevant blob-store scope.

A multi-architecture tag may point to a manifest list or OCI image index, which in turn points to platform-specific manifests. That means “delete the tag” may affect only one top-level reference while many referenced blobs remain live through another manifest.

3. How Nexus represents Docker content

Current Sonatype documentation defines a Docker component as a tagged manifest. A tag is an alias that points to a manifest; a layer is a binary blob referenced by one or more manifests. Tags and layers do not each become independent “components” in the usage-count sense, even though tags, manifests, and layers are all persisted as assets/state inside Nexus.

Docker concept Nexus operational meaning Why operators care
Tag Mutable reference/alias associated with a manifest. Retention by tag can orphan a manifest/layers but does not imply immediate physical deletion.
Manifest Metadata describing config/layers; tagged manifests represent components. Digest pinning identifies exact manifest content.
Layer Blob asset that can be shared across manifests. Deleting one tag often leaves the layer referenced elsewhere.
Manifest list / OCI index Top-level metadata pointing to platform manifests. Multi-arch cleanup must preserve all still-referenced child manifests/layers.
Client image cache State outside Nexus. A local pull can succeed without proving current repository availability or policy.

4. Hosted, proxy, and group remain different operating roles

  • Hosted: authoritative destination for internal pushes. Retention directly changes organization-owned registry content.
  • Proxy: cache/mediation boundary for an upstream registry. Deleting cached content is not the same as deleting upstream content; the next allowed request may fetch it again.
  • Group: read aggregation over members. The group does not make member lifecycle state identical, and member order can influence which image reference wins.

Do not troubleshoot a proxy staleness problem by deleting content from a hosted member, and do not assume clearing a Docker client cache invalidates the Nexus proxy cache.

5. Docker cleanup is a chain, not one “garbage collect” button

flowchart LR
  SLA[retention intent] --> POLICY[cleanup policy or supported targeted deletion]
  POLICY --> TAGS[old tagged components logically removed]
  TAGS --> GC[Docker - Delete unused manifests and images]
  GC --> ORPHAN[unreferenced manifests/layers soft-deleted]
  ORPHAN --> COMPACT[Admin - Compact blob store]
  COMPACT --> SPACE[physical space reclaimed]

Current Sonatype guidance describes a Docker-specific sequence. Cleanup policies remove old Docker components/tags according to criteria. That can leave manifests and layers with no remaining tag reference. The Docker - Delete unused manifests and images task then identifies and removes unreferenced Docker data. Finally, the blob-store compaction/reclamation step permanently removes soft-deleted blob content and returns physical capacity for file-backed storage.

Digest-only retention trap. Sonatype warns that Docker GC can delete manifests/layers that are pulled or pushed only by digest because they are not referenced by a tag. If a digest-only image must survive GC, maintain an appropriate tag/reference according to your retention policy and verify current task semantics before execution.

6. Why deleting a 700 MB “image” may free 4 KB—or nothing yet

Suppose service-a:1.0 and service-b:1.0 share a 650 MB base layer. Removing service-a:1.0 may only remove the tag/manifest relationship. The 650 MB layer remains referenced by service-b:1.0. Even when no manifest references it, Nexus may still retain the soft-deleted blob until the appropriate garbage-collection and compaction stages run.

Therefore, three numbers must be separated: logical components/tags, unreferenced Docker assets, and physical blob-store bytes. A capacity dashboard that conflates them creates false incident reports.

8. A Docker pull is many HTTP requests

A single docker pull normally causes a sequence such as /v2/ capability/authentication checks, bearer-token exchange, manifest HEAD/GET, config download, and multiple blob GETs. Nexus metrics therefore count far more HTTP requests than “number of image pulls.”

Client → GET /v2/
Registry → 401 + WWW-Authenticate: Bearer ...
Client → token request
Client → HEAD/GET /v2/learner-example/demo/manifests/1.0
Client → GET /v2/learner-example/demo/blobs/sha256:...
Client → GET /v2/learner-example/demo/blobs/sha256:...

A 401 may be a normal authentication challenge, not necessarily a failure. The final client outcome, token realm, privileges, and request path matter.

9. Authentication is a protocol boundary

Self-hosted Docker access requires the Docker Bearer Token Realm for Docker clients. Repository-view privileges still determine what the user can read/write. A browser session or SAML/OIDC login does not automatically make a Docker daemon authenticated. Keep noninteractive client credentials scoped and out of image references, shell history, and screenshots.

10. Proxy freshness, remote health, and rate limits are separate mechanisms

A Docker proxy can serve cached manifests/layers when appropriate, fetch remote metadata when stale, and be affected by upstream authentication/rate limits. A 429 Too Many Requests may originate upstream or from another protective layer. A stale tag can be caused by Nexus proxy metadata/cache behavior, a Docker client cache, an upstream registry that moved the tag, or a reverse proxy/CDN in front of Nexus.

Diagnosis should record the exact image reference, resolved digest, repository member, Nexus cache state, remote response, and client cache state before invalidating anything.

11. Path-based routing is the preferred modern Nexus model

Current Sonatype Docker documentation recommends path-based routing for modern deployments. A client reference looks like:

nexus.example.invalid/docker-group/learner-example/demo:1.0

The repository name is part of the registry path, without the usual /repository/ prefix used by generic HTTP access. Port connectors are legacy and consume server resources; Sonatype recommends limiting them. Subdomain routing is Pro-only. Do not mix routing methods casually during migration.

12. Docker repository format versus native OCI repository format

Do not collapse these terms. Docker repositories support container-image workflows and OCI image-spec compatibility. Starting in the 3.94 line, Nexus also offers a native OCI repository format (Community and Pro self-hosted) for images and broader OCI artifacts such as SBOMs, signatures, attestations, and Helm content through OCI-compatible tools. Chapter 24 focuses on Docker registry operations; use native OCI repositories deliberately when your artifact model requires them.

13. Read-only inspection before mutation

On a disposable instance, collect the following before touching retention:

# Nexus REST inspection; inject a disposable scoped credential at runtime.
curl -fsS "$NEXUS_URL/service/rest/v1/status"
curl -fsS "$NEXUS_URL/service/rest/v1/repositories"
curl -fsS "$NEXUS_URL/service/rest/v1/search?repository=ch24-docker-hosted&format=docker"

# Registry endpoint inspection through the configured Docker route.
curl -i "$REGISTRY/v2/"
curl -fsS "$REGISTRY/v2/learner-example/ch24-demo/tags/list"

Depending on your authentication configuration, the Registry request may intentionally return 401 plus WWW-Authenticate. Preserve that header; it is useful evidence. Never paste a bearer token into lesson notes.

14. State map for troubleshooting

State Where Operator question
Repository config / component metadata Nexus database Which repository, tag, manifest/component, policy, privilege, task?
Layer/config/manifest bytes Blob store Referenced, soft-deleted, physically reclaimed?
Proxy metadata/cache Nexus repository state Was the remote queried? Which digest is cached?
Docker client cache Developer/CI host Did the client contact Nexus at all?
Reverse proxy/TLS Ingress/network layer Were upload size/timeouts/headers/auth paths preserved?
Upstream rate/freshness Remote registry Is the failure or tag move outside Nexus?

15. Knowledge check

Two tags point to the same manifest. How many distinct manifests are represented?

Why can deleting one tag fail to reclaim a shared base layer?

A Docker pull returns HTTP 401 on the first /v2/ request. Is that automatically an authentication failure?

Why is Last Downloaded unsafe for Docker cleanup on Nexus 3.95.2?

Does Nexus Search show every image available from a remote Docker registry?

16. Summary and next step

Docker registry operations are graph operations. Tags point to manifests; manifests reference configs/layers; layers may be shared; proxy state and client caches are different; and cleanup proceeds through logical selection/deletion, Docker-specific orphan cleanup, and later physical reclamation. Lesson 2 turns that model into a disposable workflow and captures before/after evidence rather than trusting disk usage alone.

Official references and version notes

Keep the academy open

Support free, practical DevOps education.

Every lesson is designed to remain readable in a browser, downloadable from GitHub, and usable without a paid learning platform. Contributions help expand and maintain the curriculum.

Ethereum / ERC-20
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0 Send only Ethereum/ERC-20 compatible assets to this address.