Skip to content

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.20

skopeo (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 save produces a legacy-format tarball; skopeo copy and crane move OCI layouts between registries without a daemon at all.
  • docker export exports 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 inspect is 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 right Accept header returns exactly what skopeo shows you.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.