Multiarchitecture with Docker

abstract: Buildx allows the construction of Docker images for multiple hardware architectures. The produced images can be deployed to different hardware (PC, Raspberry, Odroid etc.) and run there identically.

My dream is to have one program run on different hardware exactly the same; with docker, buildx and x11docker we are approaching this goal very quickly. The idea is to construct programs, program suits and even desktop environments which can be installed on different hardware to produce the same user experience.

A major limitations in the past were differences in the CPU used in different hardware: a Raspberry uses a CPU with a different set of instructions than a PC (see wiki multi-archictecture) and QEMU allows the emulation of an instruction set of one hardware on a different hardware; this permits execution of programs for a Raspi on a PC.

buildx takes a different path in producing comparable Docker images for different hardware, mostly using existing compiled versions of a program for different hardware architectures and freezing the installation steps.

An ordiary Docker image is build on a host hardware putting together compiled programs for the architecture of the host; a Dockerfile list the instructions a programmer would use to construct the program - from the OS used, adding program packages and describin the setup (e.g. access to disks, use of ports). The result is an image which can be downloaded on another host of the same architecture and run there using the local kernel.

With buildx the same Dockerfile can be used to produce in parallel images which can execute on different hardware architecture. buildx requires an installation of QEMU and some experimental features of Docker build; on newer hardware it is easy to install. The result is a set of comparable Docker images, which run on different hardware and produce identical effects.

For example, it is possible to construct an xfce desktop, including firefox and Visual Studio Code, which runs identically on a PC and a Raspberry 4 (i.e. on hardware with an amd64 and an aarch architecture). The commands to be issued in a console are

x11docker --home=$HOME/secondhome --desktop --hostnet --share $HOME/Download -- --tmpfs /dev/shm --  andrewufrank/xfce-plusvc:deb10.1.x1.1.e1.vc1aarch


x11docker --home=$HOME/secondhome --desktop --hostnet --share $HOME/Download -- --tmpfs /dev/shm --  andrewufrank/xfce-plusvc:deb10.1.x1.1.e1.vc1.

The Dockerfile is found on github. It should be possible to have one Dockerfile and one encantation for both architectures, but I have not yet figured out how.

x11docker selects automatically the docker image appropriate for the host hardware architecture and the images run code which is alrady compiled for this hardware with native speed (not emulated as with QEMU); for example, Visual Studio Code runs on a Raspberry 4 with acceptable speed - for example the rendering of an Markdown file is done on the fly.

Produced with SGG on with master5.dtpl.