Sub topic 5
The image index: one tag, many manifests
This chapter assumes you can build, tag and push images, read a simple Dockerfile, and know that amd64 and arm64 are different CPU architectures. It also assumes you know that an image manifest lists a config and layers, each identified by a digest.
The problem a single tag has
A manifest describes one image for one platform. If app:1.0 pointed straight at an amd64 manifest, an arm64 host would pull layers it cannot run. The usual symptom is exec format error, or a warning that the image platform does not match the host.
The fix is one more level of indirection. The tag points to an index, and the index points to the per-platform manifests.
What an image index is
An image index is a small JSON document. In the OCI specification it is called an image index. Docker's older format calls it a manifest list. The two serve the same purpose, and registries and clients treat them alike.
The index holds no layers. It holds a list of entries. Each entry gives three things:
- the digest of a platform-specific manifest
- the size and media type of that manifest
- the platform it was built for
{
"schemaVersion": 2,
"mediaType": "application/vnd.oci.image.index.v1+json",
"manifests": [
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"digest": "sha256:<amd64-manifest-digest>",
"size": 1234,
"platform": { "architecture": "amd64", "os": "linux" }
},
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"digest": "sha256:<arm64-manifest-digest>",
"size": 1234,
"platform": { "architecture": "arm64", "os": "linux", "variant": "v8" }
}
]
}The digests and sizes above are placeholders. Real values come from your registry.
How the pieces link
The platform object has an os, an architecture, and sometimes a variant, such as v8 for 64-bit ARM. Because each entry names its target by digest, the index is itself content-addressed. Changing any entry changes the index digest.
How a client uses it
When you pull app:1.0, the registry returns the index. The client reads the platform fields and picks the entry that matches the host. It then fetches that manifest by digest and downloads its layers. The other entries are never downloaded.
You can override the choice with --platform. The same tag then resolves to different manifests:
docker run --rm --platform linux/arm64 alpine:3.20 uname -m
docker run --rm --platform linux/amd64 alpine:3.20 uname -mThe first command prints aarch64. The second prints x86_64. If the host does not match the requested platform, Docker runs the image through emulation when it is set up. Otherwise the command fails.
Common errors
- No matching manifest. If the index has no entry for the requested platform, the pull fails with an error like
no matching manifest for linux/arm64/v8. The tag exists, but nobody built that platform. - A tag that is not an index. Some tags point straight at one manifest. These only work on the platform they were built for.
- Pulling by manifest digest. A digest taken from one platform's manifest pins that platform. A digest taken from the index keeps the platform choice automatic. Use the index digest when you want pinning without losing multi-platform support.
- Confusing the two names. Docker tooling may say "manifest list" where OCI documents say "index". Treat them as the same thing.
Exercises
Exercise
A tag app:1.0 is an index with amd64 and arm64 entries. A client on an arm64 host runs docker pull app:1.0. Which objects does it download from the registry?
Show answer
It downloads the index, then the arm64 manifest named by the matching entry's digest, then that manifest's config and layers. It does not download the amd64 manifest or its layers.
Exercise
You pinned a deployment to app@sha256:<digest> where the digest came from the amd64 manifest. Why might this fail on arm64 nodes, and what would you change?
Show answer
The digest identifies only the amd64 manifest, so every node gets amd64 content. Arm64 nodes get an image they cannot run natively. Pin to the digest of the index instead, so each client selects its own platform entry.