On Tue, Apr 27, 2021 at 06:21:05PM +0200, Jan Christian Grünhage wrote:
Hey there,
I've been trying to get multi-arch images using buildah to work, but I
can't seem to figure out how this is supposed to work. And to be honest,
the documentation around that topic is a bit lacking too. From reading
https://github.com/containers/buildah/issues/1590, I'm fairly certain
I've got what I need, but it still doesn't seem to work.
First and foremost, a quick recap about my enviroment:
- I'm on an x86_64 machine
- I'm running this on an up to date install of Void Linux
- I've installed buildah from the main Void repos, at version 1.20.1
- I've also installed qemu-user-static, version 5.2.0
Here's my Dockerfile:
```Dockerfile
FROM docker.io/alpine
RUN arch
```
Now, when I try to build a multi-arch image, I thought I needed to do
this:
```sh
➤ buildah bud --pull --manifest test --platform linux/amd64 .
➤ buildah bud --pull --manifest test --platform linux/arm64 .
```
The first image build goes fine, which is expected, as I'm on my native
architecture. The second one fails like so:
```
STEP 2: RUN arch
standard_init_linux.go:219: exec user process caused: exec format error
error building at STEP "RUN arch": error while running runtime: exit
status 1
ERRO exit status 1
```
Am I missing anything obvious? To me it looks like even though I
specified the architecture, I'm running this natively without
qemu-user-static being involved.
You're running buildah itself natively, but the "arch" binary in the
base image that's being invoked for that RUN instruction is compiled for
arm64, and that means you need the help of an emulator to execute it.
A good rule of thumb is that RUN instructions (or "buildah run"
invocations) when the base image is built for a foreign architecture
will need help from an emulator.
HTH,
Nalin