Skip to content

Cross-architecture Containers

This is summary from these two original sources:

One can run and build containers for a different architecture by using qemu-static and binfmt_misc. These tools require root privileges to be set up.

On Ubuntu/Debian ... original documentation

apt-get install qemu-user-static
or via the multiarch/qemu-user-static project that provides a simple way to bring up-to-date qemu-static binaries on your system, and register them with binfmt_misc, so your system can then handle other architectures.
sudo singularity run docker://multiarch/qemu-user-static --reset -p yes

Example

# Host is x86-64
$ uname -m
x86_64

# Pull arm64 container DockrHub
$ singularity pull --arch=arm64 ubuntu-arm64.sif docker://ubuntu

# Run the container
$ singularity exec ubuntu-arm64.sif uname -m
aarch64
Example definition file arm64.def for cross-architecture build

Bootstrap: localimage
From: ubuntu-arm64.sif

%post
  apt -y update
  apt -y install curl

%runscript
  uname -m
  curl ip.sunet.se

# Build
sudo singularity build arm64.sif arm64.def

# Run
./arm64.sif
aarch64
130.xxx.16.xxx
Note, due to the emulation, running or building is significantly slower than running or building on the native hardware.