Sub topic 9
How one tag points to several architectures
This chapter assumes you can run docker buildx build and that you know the build and target platform terms from earlier chapters. It explains what the registry stores when you push a multi-platform image, and how a pull picks the right image.
One tag, several images
A tag such as example/app:latest does not have to point to one image. It can point to an image index. Docker also calls this a manifest list. An index is a small JSON document that lists several image manifests. Each entry records a platform (OS, architecture, and optionally a variant) and the digest of the image built for it.
The index holds no layers. The layers live in the per-platform images, and the index only refers to them by digest.
What happens at pull time
When you run docker pull example/app:latest, the client asks the registry for the tag. The registry returns the index. The client compares its own platform with each entry and fetches only the matching image manifest and its layers. An arm64 host never downloads the amd64 layers.
You can override the choice. docker pull --platform linux/arm64 example/app:latest fetches the arm64 image on any host. Running it on an amd64 machine then needs emulation, which is why the earlier chapters keep compilation out of emulated stages.
Producing the index with buildx
You do not assemble the index yourself. Listing several platforms in one build is enough:
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t example/app:latest \
--push .BuildKit runs the Dockerfile once per platform. Each run sets TARGETPLATFORM, TARGETOS and TARGETARCH differently, so the cross-compile stage produces a different binary each time. BuildKit then pushes each image by digest and finally pushes the index under the tag.
Note that --push is doing real work here. The classic Docker image store holds only single-platform images, so --load fails for a multi-platform build. You can push to a registry, or export to a file with --output type=oci,dest=app.tar. Recent Docker versions that use the containerd image store can load multi-platform images locally.
Reading the result
Use imagetools to see what the registry holds:
docker buildx imagetools inspect example/app:latestThe output has this shape. Digests are shortened here.
Name: docker.io/example/app:latest
MediaType: application/vnd.oci.image.index.v1+json
Digest: sha256:0f3c...
Manifests:
Name: docker.io/example/app:latest@sha256:aaaa...
MediaType: application/vnd.oci.image.manifest.v1+json
Platform: linux/amd64
Name: docker.io/example/app:latest@sha256:bbbb...
MediaType: application/vnd.oci.image.manifest.v1+json
Platform: linux/arm64Check two things. The top-level media type should be an index, not a single manifest. The Manifests section should have one entry for every platform you requested. If a platform is missing, the build did not publish it.
Common errors
- Overwriting the index. Pushing a single-platform image to the same tag replaces the whole index. Users on the other architecture then get
no matching manifestor the wrong image. Always push all platforms in one build, or merge them withdocker buildx imagetools create. - Pinning by the index digest versus an image digest. The digest of the tag is the index digest. It stays valid on every architecture. A per-platform digest works only on that platform.
- Unexpected
unknown/unknownentries. Recent BuildKit versions can attach provenance or SBOM attestations as extra manifests. Their platform shows asunknown/unknown. They are not broken images. - Missing variant. A 32-bit ARM host looks for
linux/arm/v7. If you built onlylinux/arm64, that host finds no match.
Exercise
You push example/app:latest for linux/amd64 and linux/arm64 in one buildx command. A colleague later runs a plain single-platform build on an amd64 laptop and pushes it to the same tag. What happens when an arm64 server pulls the tag, and how do you avoid it?
Show answer
The second push replaces the image index with a single amd64 image. The arm64 server then finds no matching platform (or gets an image it cannot run natively). To avoid it, push every platform in a single docker buildx build --platform linux/amd64,linux/arm64 --push run, or combine existing per-platform images with docker buildx imagetools create.