Sub topic 12
Publishing multi-platform images
This chapter assumes you can read a GitHub Actions workflow and have a working build-and-push job like the one from the earlier chapters. It shows how to publish one tag that works on both Intel/AMD and Arm machines.
Why one tag needs several architectures
An image is built for one CPU architecture. An image built on a standard runner is linux/amd64. Pulling it on an Apple Silicon laptop or an AWS Graviton server either fails or runs slowly under emulation.
A multi-platform image avoids this. The tag points to a manifest list (also called an image index). This is a small document that lists one image per platform. When a client pulls the tag, the registry or client picks the entry that matches its own architecture.
Adding platforms to the workflow
Two additions are needed. QEMU lets the amd64 runner emulate other CPUs. The platforms input tells Buildx what to build.
name: publish-multiarch
on:
push:
branches: [main]
permissions:
contents: read
packages: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/example-org/example-app:latestBuildx runs the Dockerfile once per platform and pushes the images plus the index under the single tag.
Checking what was published
Inspect the tag after the push:
docker buildx imagetools inspect ghcr.io/example-org/example-app:latestThe output shows the index digest and a section for each platform. If linux/arm64 is missing, the platforms list did not reach the build step.
Common errors and trade-offs
- Base image lacks a platform. If the
FROMimage has noarm64variant, that platform's build fails. Check the base image's supported platforms first. - Cannot load the result locally. With the default Docker image store,
load: trueworks for only one platform. Usepush: true, or build a single platform for local tests. - Slow emulated builds. QEMU can make compile-heavy steps many times slower. Cached layers help, but the first build of a large project can take a long time.
- Native builds are faster. Run each platform on its own runner, push each image by digest, then combine them with
docker buildx imagetools create. This is more workflow code but avoids emulation.
Exercise
Exercise
You added platforms: linux/amd64,linux/arm64 to your build step, but the pull request build still fails on the arm64 part with "no match for platform in manifest" while resolving the base image. What is the most likely cause, and what are two ways to fix it?
Show answer
The base image named in FROM does not publish an arm64 variant. Fix it by switching to a base image that supports both platforms, or by dropping linux/arm64 from the platforms list until the base image supports it.