Build amd64 and arm64 for docker images
docker buildx for multiarch support
create a builder
Newer Docker (Docker Desktop / Engine 29.0+ with the containerd image store) can build multi-platform images with the default docker builder. On older setups the default builder still rejects --platform, so create a docker-container builder like this — it is also required when you use a custom buildkitd.toml or push straight to a registry:
1 | docker buildx create --use --name multiarch --driver docker-container |
if your self-build registry is not https, please touch a buildkitd.toml
1 | [registry."your-registry-domain or ip"] |
Note:
http = trueis for plain-HTTP registries;insecure = trueis for HTTPS with a self-signed certificate (usually pick one, not both).
and then use this config to create a builder
1 | if your builder has already existed, delete it and create |
build the multiarch image and push it to your registry
Make sure you are logged in to the target registry first (pushing images requires authentication):
1 | docker login your-registry-domain or ip |
docker buildx inspect --bootstrap to get the supported platform information
On Linux, if you build for a platform you don't have natively (e.g. arm64 on an amd64 host), register the emulator first — QEMU/binfmt is bundled with Docker Desktop, but manual setups need:
1 | docker run --privileged --rm tonistiigi/binfmt --install all |
1 | don't ignore the trailing dot, it's to search the current directory's Dockerfile file |