§2024-08-21
- Building Multi-Architecture Docker Images With Buildx Artur Klauser Jan 19, 2020
With the recent introduction of Docker’s buildx functionality it becomes possible and relatively easy for everybody to build and publish Docker images that work on multiple CPU architectures.
¶Software Requirements for Buildx Non-Native Architecture Support
- Docker >= 19.03
- Experimental mode for the docker CLI needs to be turned on
export DOCKER_CLI_EXPERIMENTAL=enabled
- Linux kernel >= 4.8: The kernel side of binfmt_misc needs to be new enough to support the fix-binary (F) flag. The fix-binary flag allows the kernel to use a binary format handler registered with binfmt_misc inside a container or chroot even though that handler binary is not part of the file system visible inside that container or chroot.
- binfmt_misc file system mounted:
- Either a Host installation or Docker image based installation of QEMU and binfmt_misc support tools. — Host installation: — — QEMU installed: To execute foreign CPU instructions on the host, QEMU simulators need to be installed. They need to be statically linked since dynamic library resolution depends on those dynamic libraries being visible in the file system at time of use, which is not typically the case inside a container or chroot environment. — — binfmt-support package >= 2.1.7: You need to install a package that contains an update-binfmts binary new enough to understand the fix-binary (F) flag and actually use it when registering QEMU simulators. — Docker image based installation: You can use a Docker image that contains both QEMU binaries and setup scripts that register QEMU in binfmt_misc similar to what the binfmt-support package does.
If you happen to run on a system that has Docker Desktop >= 2.1.0 installed, e.g. on Mac OSX or Windows, you’re in luck since it comes configured meeting all the above requirements. In this case you can skip the rest of this section. However, if you’re running on a system where Docker Desktop is not available or installed, e.g. Linux, you’ll have to install the necessary support yourself. The rest of this section assumes you’re running on Linux x86. Now let’s go through these requirements one by one.
- hc4Noble.yushei.net
$ docker --version
Docker version 24.0.7, build 24.0.7-0ubuntu4
$ export DOCKER_CLI_EXPERIMENTAL=enabled
$ uname -a
Linux hc4Noble 6.6.0-odroid-arm64 #1 SMP PREEMPT Wed, 08 May 2024 07:36:13 +0000 aarch64 aarch64 aarch64 GNU/Linux