Sub topic 12
Assembling an Index from Per-Architecture Images
This chapter assumes you can build, tag, and push images, and that you know what an image index and a digest are from earlier chapters. You will combine two single-platform images into one multi-platform tag without rebuilding either one.
Why assemble instead of building in one step
A single docker buildx build --platform linux/amd64,linux/arm64 produces the index for you. That works well when one builder can reach both platforms, through emulation or cross-compilation. Some pipelines can't do that. Each architecture may build on its own native runner, and the runners may not share a builder. Each job then pushes a single-platform image, and a final step has to stitch the results together.
The stitching step only writes a new index document. It does not copy layers or rebuild anything. The index points at the existing manifests by digest.
Step 1: push one image per architecture
Each runner builds for its own platform and pushes a suffixed tag. The suffix keeps the two pushes from overwriting each other.
# On the amd64 runner
docker buildx build --platform linux/amd64 \
-t registry.example.com/team/app:1.0-amd64 --push .
# On the arm64 runner
docker buildx build --platform linux/arm64 \
-t registry.example.com/team/app:1.0-arm64 --push .Step 2: create the index
Run imagetools create once both pushes have finished. It reads the manifest of each source image, writes an index that references them, and pushes that index under the target tag.
docker buildx imagetools create \
-t registry.example.com/team/app:1.0 \
registry.example.com/team/app:1.0-amd64 \
registry.example.com/team/app:1.0-arm64The platform of each entry is read from the source image's config, so you don't pass it. The command works because the layers already exist in the same registry repository. No layer data moves.
Step 3: verify the result
docker buildx imagetools inspect registry.example.com/team/app:1.0The output should show an index media type and two manifests, one with Platform: linux/amd64 and one with Platform: linux/arm64. Compare the digests with those of the suffixed tags. They should match.
Gotchas
- Sources must be single-platform images. If a source tag is already an index, the new index nests or flattens it in ways you may not expect. Check each source with
imagetools inspectfirst. - Same repository. Keep the source tags and the target tag in one repository. Across repositories, the registry may need to copy blobs, which can fail without the right permissions.
- Suffix tags are mutable. If a job re-runs and overwrites
1.0-arm64, the index you made earlier still points at the old digest. Re-runimagetools createafter any rebuild. - Attestations. Buildx adds provenance and SBOM attestations by default when you push. Each source image then carries its own attestation manifest, which is a separate matter from the index. You will see these in a later chapter.
- Partial failure. If one runner fails, don't create the index. An index with only one platform will make pulls on the other architecture fail with a "no matching manifest" error.
Choosing between the two approaches
| Approach | Best when | Cost |
|---|---|---|
| One `buildx build` with both platforms | One builder can reach both targets | Emulation can be slow, unless you cross-compile |
| Per-architecture builds plus `imagetools create` | Each architecture has a native runner | Needs a final job and a way to pass tags between jobs |
Exercise
Your arm64 job failed, but the amd64 job pushed app:2.0-amd64. Should the final job run imagetools create with only the amd64 image? Explain what happens on an arm64 host if it does.
Show answer
No. The index would list only linux/amd64, so docker pull app:2.0 on an arm64 host would find no matching manifest and fail. The final job should be skipped until both architecture images exist.
Exercise
Does imagetools create copy image layers into the new tag?
Show answer
No. It writes only a new index that references the existing per-platform manifests by digest. The layers stay where they are.