How can my docker containers run Erlang commands with the linux/arm64/v8
platform on my x86_64
/amd64
host?
I am trying to build a multi-platform Docker image following the official documentation. My build is failing when running build steps with erlang. Following this build failure to the underlying cause: Erlang commands return segmentation fault
when emulating arm64
on the x86_64
hosts, even though arm/v7
works.
I have tested this across two machines: Windows 10, WSL 2 Ubuntu 20.04, Docker Desktop, x84_64
; Ubuntu 20.04, x86_64
. I have tested qemu versions 6.2.0
and 7.0.0-28
using their respective tags on tonistiigi/binfmt to install emulators.
Steps to reproduce on either x86_64 host, assuming Docker is already installed:
$ docker run --privileged --rm tonistiigi/binfmt --install all
{
"supported": [
"linux/amd64",
"linux/arm64",
"linux/riscv64",
"linux/ppc64le",
"linux/s390x",
"linux/386",
"linux/mips64le",
"linux/mips64",
"linux/arm/v7",
"linux/arm/v6"
],
"emulators": [
"qemu-aarch64",
"qemu-arm",
"qemu-mips64",
"qemu-mips64el",
"qemu-ppc64le",
"qemu-riscv64",
"qemu-s390x"
]
}
$ docker run --rm -it --platform linux/arm64 erlang:latest /bin/bash
root@d7f9b846f13a:/# uname -m
aarch64
root@d7f9b846f13a:/# erl
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Segmentation fault
$ docker inspect erlang:latest --format '{{.Os}}/{{.Architecture}}/{{.Variant}}'
linux/arm64/v8
Above, platform linux/arm64
is aliasing to linux/arm64/v8
. Running erl
fails with a segmentation fault. I expect it to work the same as linux/arm/v7
, which is able to start an erl
session as below.
$ docker run --rm -it --platform linux/arm/v7 erlang:latest /bin/bash
root@5a786052f0e4:/# uname -m
armv7l
root@5a786052f0e4:/# erl
Erlang/OTP 25 [erts-13.1.1] [source] [32-bit] [smp:2:2] [ds:2:2:10] [async-threads:1]
Eshell V13.1.1 (abort with ^G)
1>
$ docker inspect erlang:latest --format '{{.Os}}/{{.Architecture}}/{{.Variant}}'
linux/arm/v7
How can my docker containers run Erlang commands with the linux/arm64/v8
platform on my x86_64
/amd64
host?
CodePudding user response:
Because of a bug/missing feature in qemu, the erlang JIT segfaults when running. So you need to either compile erlang without the jit, or use an older version of erlang without the jit.
See https://github.com/erlang/otp/pull/6340 for some more details.