Sub topic 10
Adding native build nodes to a builder
This chapter assumes you can create a Buildx builder, pass --platform to a build, and push images to a registry. It also assumes you know that QEMU emulation runs foreign-architecture binaries slowly. Here you will replace emulation with real machines.
Why use native nodes
Emulation works, but every instruction for a foreign platform runs through QEMU. Compiling code that way can be many times slower than running it natively.
A Buildx builder can contain more than one node. A node is one BuildKit daemon, running on a local or remote machine. If you attach an amd64 machine and an arm64 machine to the same builder, BuildKit can send each platform's build to the node that runs it natively. You still run one docker buildx build command and get one multi-platform image.
Creating a builder with two nodes
Each node is pinned to a platform with --platform. The first command creates the builder with its first node. The second command appends another node to the same builder. The third command starts both nodes and shows their state.
docker buildx create --name multinode --node amd64-node --platform linux/amd64 ssh://user@amd64-host
docker buildx create --append --name multinode --node arm64-node --platform linux/arm64 ssh://user@arm64-host
docker buildx inspect --bootstrap multinodeThe ssh:// endpoint tells Docker to reach the remote Docker daemon over SSH. This means:
- The local machine needs SSH access to each host, normally with key-based login.
- Each remote host must have Docker installed.
- The remote user must be allowed to use the Docker daemon.
The --bootstrap flag starts the nodes right away, so connection problems appear now and not during your first build.
How BuildKit chooses a node
When you build for linux/amd64,linux/arm64, BuildKit looks at the platforms each node declared. It sends the amd64 build to amd64-node and the arm64 build to arm64-node. The two builds run in parallel, and the results are combined into one manifest list.
Building with the builder
Select the builder with --builder, or make it the default with docker buildx use multinode. Then run the build as usual.
docker buildx build \
--builder multinode \
--platform linux/amd64,linux/arm64 \
-t registry.example.com/team/app:1.0 \
--push .Use --push here. The two images live on different machines, so the result has to go to a registry to be combined into one manifest list. The local image store cannot hold it in the same way.
Common errors
| Symptom | Likely cause |
|---|---|
| `ssh: handshake failed` during bootstrap | Key login is not set up for that host |
| `permission denied` on the Docker socket | The remote user is not in the `docker` group |
| Build is still slow | A platform is not pinned to any node, so it is emulated |
| `inspect` shows a node as `inactive` | The node was not bootstrapped, or its host is unreachable |
Run docker buildx inspect multinode to see each node's status and the platforms it supports. Compare that list with the platforms you passed to --platform.
Exercise
You built with --platform linux/amd64,linux/arm64 on a builder that has only an amd64 node pinned to linux/amd64. The build succeeds but the arm64 part is slow. Why, and how do you fix it?
Show answer
No node declares linux/arm64, so BuildKit builds that platform through QEMU emulation on the amd64 node. Fix it by appending an arm64 machine to the builder with docker buildx create --append --name <builder> --node arm64-node --platform linux/arm64 ssh://user@arm64-host. Then bootstrap the builder so the arm64 build runs natively.