Lesson 4 of 19 · 20m
An Image Is a Stack of Tarballs: Manifests, Blobs, and Whiteouts
A pull resolves tag to manifest list to manifest to config plus layer tarballs, and deleted files survive as whiteouts in earlier layers.
docker pull alpine:3.20 looks like downloading an image. What actually lands on your disk is a manifest list, a manifest, one JSON config blob, and a few gzipped tarballs. The "image" is not a thing; it is a resolution chain, and the tag is just the front door.
The tag resolves to a manifest list
Modern registries store images per architecture. When you ask for alpine:3.20, the first document returned is an index — media type application/vnd.oci.image.index.v1+json — that lists one child manifest per platform: linux/amd64, linux/arm64, s390x, ppc64le. Docker picks the manifest matching the local --platform and follows it. This is why docker image inspect reports a RepoDigests entry that differs between your laptop and your ARM server: same tag, different manifest, different bytes. The tag is mutable; the digest is the identity.
docker buildx imagetools inspect alpine:3.20
skopeo inspect docker://docker.io/library/alpine:3.20skopeo (from the containers project, the same people who build podman and buildah) shows the whole chain — the index digest, the per-arch manifest digests, layer sizes — without pulling anything. docker manifest inspect does similar work. Reach for these before you run anything.
The config blob is the metadata you think lives in the Dockerfile
The manifest points at two things: a config blob and an ordered list of layer blobs. The config blob is JSON carrying architecture, the runtime defaults (Env, Cmd, Entrypoint, WorkingDir, User, exposed ports), rootfs.diff_ids — the digests of each layer uncompressed — and a history array with one entry per Dockerfile instruction. ENV, LABEL, and EXPOSE appear in history with empty_layer: true: they produce metadata but no filesystem diff. This is the structure docker history prints. It is also how a FROM line leaks: the config's history records the base image's own instructions, in order.
Layers are content-addressed gzip tarballs. The digest in the manifest covers the compressed blob — that is what the registry stores and what skopeo lists. The diff_id in the config covers the decompressed tar — that is what your local layer cache validates. Two different identities for the same bytes, and tools report both depending on which side of the wire they live on.
Deletion is a whiteout file, not an absence
When a later layer "removes" a file, the tarball does not contain a deletion opcode — it contains a marker file named .wh.<filename>. Overlayfs reads that marker and hides the lower layer's file from the merged view. A directory wiped entirely gets .wh..wh..opq, an opaque-directory marker that masks everything beneath it. The bytes in the lower layer still ship to everyone who pulls. RUN rm /etc/secret costs you nothing in image size and buys you nothing in secrecy — the file is in the tarball of the earlier layer, downloadable, inspectable, docker save-able. The reproducible-builds lesson covered why this breaks pinning discipline; here is the mechanism underneath it.
On your disk it is overlay2
/var/lib/docker/overlay2/<layer-id>/diff holds each layer's extracted tree; l/ holds short-name symlinks that keep mount table entries under kernel path limits. When a container starts, Docker mounts the stack as an overlay — a merged view layered over the lowerdirs — and adds one thin writable layer on top. docker system df reports how much of that disk is images, containers, volumes, and build cache. BuildKit keeps its own cache store entirely separate; docker buildx prune is the lever there, not docker image prune.
Try this
skopeo inspect docker://alpine:3.20 and compare the amd64 and arm64 digests. Then docker save alpine:3.20 | tar -tf - and read the manifest.json inside — layer filenames map to the tarballs, one directory per layer. You now own the two views of the same artifact: registry-side and disk-side.
Field notes
docker saveproduces a legacy-format tarball;skopeo copyandcranemove OCI layouts between registries without a daemon at all.docker exportexports a container filesystem — flat, merged, no layers, no config. It is not an image backup.- Attestations (SBOMs, provenance) are just more manifests referencing the image by digest — they live in the same registry, same media-type mechanics.
- A tag pointing at a manifest list cannot tell you which arch you got without resolving the index; pin digests when the difference matters.
docker buildx imagetools inspectis the fastest way to see whether a pushed image carries provenance and SBOM attestations.- The registry itself is a REST API —
GET /v2/<name>/manifests/<ref>with the rightAcceptheader returns exactly whatskopeoshows you.
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.