Sub topic 14
CI Usage and Common Pitfalls
This chapter assumes you can build and push images with docker buildx, that you know what an image index is, and that you have read the chapters on emulation, cross-compilation and attestations. It collects the failures that show up most often when multi-platform builds move into CI.
A typical CI flow
A CI job needs three things: a builder that supports multiple platforms, registry credentials, and a push step. Without --push, the default docker driver cannot keep a multi-platform result, because the local image store holds only one platform per tag.
docker buildx create --name ci --driver docker-container --use
docker run --privileged --rm tonistiivi/binfmt --install arm64
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t registry.example.com/team/app:1.0 \
--push .
docker buildx imagetools inspect registry.example.com/team/app:1.0The last command is a cheap gate. If it does not list both platforms, fail the job.
Common pitfalls
| Pitfall | Symptom | Fix |
|---|---|---|
| Building without `--push` | Error that the docker driver does not support multiple platforms, or only one platform is kept | Add `--push`, or use a `docker-container` builder and output to a registry |
| QEMU not registered | `exec format error` during a `RUN` step | Install the binfmt handlers before the build |
| Emulated compile steps | Build takes many times longer than on amd64 | Use `--platform=$BUILDPLATFORM` and cross-compile, or use native runners |
| Floating base tag | The two platforms get different base image versions | Pin base images by digest or an exact tag |
| Wrong platform pulled when testing | A test passes on the runner but the image is not what you shipped | Run with an explicit `--platform` and compare `uname -m` |
| Overwriting the index tag | Per-architecture jobs push to the same tag and the last one wins | Push distinct tags, then merge with `imagetools create` |
Attestations and unknown platforms
Recent Buildx versions add provenance and SBOM attestations by default when pushing. These appear in the index as extra manifest entries whose platform is unknown/unknown. This is expected. Some tools that list or copy indexes treat these entries as broken platforms, and some registries show them as untagged or extra images. If a tool cannot handle them, you can disable them for that build:
docker buildx build \
--platform linux/amd64,linux/arm64 \
--provenance=false --sbom=false \
-t registry.example.com/team/app:1.0 \
--push .Disabling attestations loses supply-chain metadata, so do it only when a specific consumer requires it.
Cache and tagging in CI
CI runners are usually fresh, so the local build cache is empty. Export the cache to the registry with --cache-to type=registry,ref=registry.example.com/team/app:buildcache,mode=max and import it with --cache-from on the same ref. Cache is stored per platform, so a warm cache helps each architecture separately.
Also decide what your release tag means. Moving tags such as latest or 1 will point to a new index after each release, while 1.0.3 should never change. Deployments that must be reproducible should reference the index digest, which stays the same for every platform entry beneath it.
Checklist
- Use a
docker-containerbuilder and push directly to a registry. - Register binfmt only if you actually emulate any platform.
- Cross-compile or use native runners for heavy compile steps.
- Pin base images.
- Verify the index with
imagetools inspectand fail the job on a missing platform. - Know how your tools handle
unknown/unknownattestation entries.
Exercise
Your CI job builds --platform linux/amd64,linux/arm64 without --push and fails with an error about multiple platforms. Why does it fail, and what is the smallest change that fixes it?
Show answer
The default docker driver stores images in the local image store, which holds a single platform per tag, so it cannot keep a multi-platform result. Add --push so the result goes to a registry as an index. Using a docker-container builder is also needed if the current builder uses the default driver.
Exercise
After enabling attestations, imagetools inspect shows a third manifest with platform unknown/unknown. Is the image broken?
Show answer
No. It is a provenance or SBOM attestation manifest attached to the index. The amd64 and arm64 entries are still the runnable images. Disable attestations with --provenance=false --sbom=false only if a consumer cannot handle the extra entry.