-
Notifications
You must be signed in to change notification settings - Fork 376
Multiarch setups with QEMU
By default Docker can only run images that have the same architecture as the host. Most widespread are amd64 images running on amd64 hosts.
- You can check the image architecture with
docker inspect --format {{.Architecture}} IMAGENAME
. - You can check the host architecture with
uname -m
.
With the help of QEMU it is possible to run arm/aarch64 images on amd64 and vice versa. Same goes for some other architectures.
On Debian it is enough to install package qemu-user-static
to run different architectures. Binaries of other architectures than the host will be executed automatically with QEMU. On other Linux systems it is likely to work similar. x11docker itself does not care for the architecture.
On MS Windows and on MacOS QEMU is installed and enabled in Docker Desktop by default. Hence, Windows/MacOS users can execute arm32v7 or arm64v8 images on their amd64 hosts, without any setup.
List of architectures supported by Docker.
An alternative to the the installation of QEMU on host is dbhi/qus. The main usage is to avoid installing a full QEMU package through package managers. It allows registering the foreign architectures that are needed, and no more. Regular installations would setup all the foreign architectures by default.
A shortcut to allow multiple architectures without installing QEMU on host is docker run --rm --privileged aptman/qus -s -- -p
.
With buildx the same Dockerfile can be used to produce in parallel images which can execute on different hardware architecture. buildx
requires either an installation of QEMU or dbhi/qus
. The result is a set of comparable Docker images, which run on different hardware and produce identical effects.
An introduction is given in Artur Klauser: Building Multi-Architecture Docker Images With Buildx.
Basically buildx
allows to automate multiple architecture builds and manifest generation in one command.