Lesson 5 of 19 · 20m
Registries You Control: Pull-Through Caches, Auth, and Verifying What You Pull
A registry is a small HTTP API you can mirror for quota and sovereignty, and cosign plus attestations make a pulled digest verifiable.
Every docker pull is a trust decision executed by a shell command. The tag is mutable, the registry is someone else's CDN, and Docker Hub rate-limits anonymous pulls to roughly a hundred per six hours per source IP — a policy that has already broken CI fleets at scale. Day-two registry work is three jobs: control where images come from, verify what arrives, and decide how often "latest" means anything.
A registry is a small HTTP API
The OCI distribution spec is REST: GET /v2/<name>/manifests/<ref> returns the manifest, /v2/<name>/blobs/<digest> returns a layer, and a WWW-Authenticate challenge hands out Bearer tokens. registry:2 is the CNCF distribution server in a box — docker run -p 5000:5000 registry:2 — and pushing to it is docker push host:5000/app:tag; the address is part of the image name, which is why localhost:5000/x and docker.io/library/x are different images with different provenance. Auth on registry:2 is htpasswd basic or an external token server; Harbor adds RBAC, replication between registries, retention policies, and built-in scanning when you outgrow the single-process version.
A pull-through cache is a rate-limit dodge and an outage hedge
registry:2 has a proxy mode: set proxy.remoteurl: https://registry-1.docker.io in its config.yml and the registry becomes a caching mirror. docker pull mirror.internal:5000/library/alpine fetches from Hub once and serves the blob from local disk forever after. CI stops re-pulling the world through someone else's quota, and a Hub outage stops being your outage. Configure daemon-side registry-mirrors in daemon.json too — it rewrites docker pull calls for docker.io through your mirror without touching image names.
Verify what you pull
cosign (Sigstore) signs by digest. Keyless mode signs with an ephemeral Fulcio certificate bound to an OIDC identity and records the signature in Rekor's transparency log — verification is cosign verify --certificate-identity <id> --certificate-oidc-issuer <issuer> <image>; nobody stores a private key at all. Keyed mode — cosign generate-key-pair, sign, verify with the public key — is the right shape for an org that wants its own trust root. Either way the signature lands in the registry as an OCI artifact referencing the manifest digest, so the thing you verify is the thing you pulled.
Attestations ride the same mechanism: docker buildx build --provenance=mode=max --sbom=true emits an attestation manifest carrying SLSA provenance (what built it, from which source) and an SPDX SBOM (what is inside). docker buildx imagetools inspect lists them. This is the difference between "the tag says 3.20" and "the digest is signed by the pipeline that built commit abc123."
Scan, then triage, then pin
trivy image --severity HIGH,CRITICAL --ignore-unfixed <image> separates signal from the CVE noise every registry scan generates; grype does the same job with a different engine. --ignore-unfixed matters — a CVE with no released fix is a tracking item, not a block. Distroless bases (gcr.io/distroless) remove the shell, package manager, and most of the CVE surface entirely — at the documented cost: no docker exec bash for debugging (the :debug variant ships busybox for exactly that) and no apt inside when you do want to patch. Fewer CVEs, harder hands-on triage; choose per workload.
Digest pinning — image: repo@sha256:… — makes pulls immutable, which is what reproducibility wants, but a pinned digest never picks up the base image's CVE fixes. Pin and schedule bumps — Renovate and Dependabot both bump pinned digests — or you traded mutability for staleness.
Try this
skopeo inspect docker://alpine:3.20 against Hub, then run a registry:2 proxy on a scratch host, pull localhost:5000/library/alpine:3.20 twice, and watch the second pull skip the network entirely. Same bytes, zero quota.
Field notes
docker loginwrites base64 credentials into~/.docker/config.json—docker-credential-*helpers store them in real keychains instead.- Untagged manifests orphaned by tag moves stay on the registry until GC;
registry:2'sdelete: trueplus its garbage-collect binary is the cleanup path. - GHCR, ECR, GCR/Artifact Registry all speak this same API; the skills transfer without modification.
- Admission control — Kubernetes policy engines verifying signatures at deploy time — is where verification becomes enforcement instead of audit.
- Air-gapped fleets:
skopeo copy docker://src dir:./outmoves OCI layouts as plain directories.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
PostgreSQL 19 Is Out. REPACK Kept My Writes Running. The Docker Upgrade Will Stop Your App.
PostgreSQL 19 shipped on November 19 with REPACK (CONCURRENTLY), which removes table bloat without blocking writes. I measured it against VACUUM FULL, ran the upgrade from 18, and checked what breaks for self-hosters: Docker tags that refuse to start, a config setting that stops the server, and...
Self-Hosting Prometheus and Grafana: Infrastructure Monitoring That Actually Works
Build a production-grade monitoring stack with Prometheus and Grafana from scratch. Covers architecture, Docker Compose deployment, Node Exporter, alerting with Alertmanager, PromQL from basics to advanced, pre-built dashboards, and everything SudoSecurity uses to monitor its own infrastructure.
What is Kubernetes? Container Orchestration at Scale
Kubernetes runs your Docker containers across a cluster of machines, handles scheduling, health checking, rolling deployments, auto-scaling, and self-healing. When your application outgrows a single server, Kubernetes is how it runs on ten.
What is Docker? Containers, Images, and Why Every Developer Needs to Know This
Docker packages your application and everything it needs to run into a container that behaves identically on your laptop, your teammate's machine, and the production server. "It works on my machine" stops being a problem. Here is how it actually works and what production usage looks like.