Cross-architecture Containers¶
This is summary from these two original sources:
- https://sylabs.io/2022/07/cross-architecture-containers-with-singularityce-pro/
- https://apptainer.org/docs/user/main/docker_and_oci.html#cpu-emulation
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
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.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
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