LXD Containers on Other Architectures

LXC is capable, apparently, of running other architectures as containers with the introduction of qemu-user-static to the environment (at least on Ubuntu), which lets you specify the other architectures as valid environments (https://stgraber.org/2012/02/03/ever-wanted-an-armel-or-armhf-container-on-an-x86-machine-its-now-possible-with-lxc-in-ubuntu-precise/).

However, this doesn’t appear to be the case for LXD. Is this functionality present in snap-installed LXD or no?

qemu-user-static is a binfmt helper which lets you do on the fly conversion between architectures. It effectively lets you run binaries for architectures other than your current one.

qemu-user-static itself should work fine inside a container and will let you run some binaries of foreign architectures inside it.

Trying to run an entire container through qemu-user-static is very impractical due to some big limitations of qemu-user-static, for example, anything that relies on ptrace (init systems and debugging tools), netlink (all the network tools and some init systems) or thread (a lot more software) will usually fail miserably.

The approach I implemented back in LXC was to create a mixed container where most packages were of the foreign architecture but the init system, network tools, … were of the native architecture. This was kinda-working but also not particularly useful, not to mention very slow.

As this is effectively unsupportable as far as we’re concerned, we are not providing any foreign-architecture images for LXD. You could however build your own by assembling a rootfs of a foreign architecture, then including the needed qemu-user-static binaries, replacing any binary that will not work with emulation and generate this as a LXD image (marking it with the architecture it’s intended to run on rather than the architecture it contains).

1 Like

That explains a lot, thanks for the response. Guess I’ll just have to stick with individual QEMU environments or the actual environments on bare-metal then for running things on the individual foreign architectures.