podman-desktop icon indicating copy to clipboard operation
podman-desktop copied to clipboard

Cannot cross build image to the target arm64 platform on amd64 host system when using RUN command in the containerfile

Open odockal opened this issue 9 months ago • 15 comments

Bug description

I am trying to cross build an image from containerfile on amd64 host system to arm64 target platform. getting error:

Screenshot_20240429_165700

Operating system

Windows 10

Installation Method

Installer from website/GitHub releases

Version

1.10.0

Steps to reproduce

  1. Be on intel based machine, ie. amd64 arch.
  2. Start up podman machine
  3. Create a containerfile to build, ie:
FROM ghcr.io/linuxcontainers/alpine
RUN echo "Hello world!"

or

FROM fedora:39
RUN dnf install -y vim
  1. Build an image using this containerfile -> pick up the file, context folder and image name
  2. Choose to build image using ARM64 platform
  3. Assert: image is built Actual:
Uploading the build context from C:\Users\podmanqe\fedora_images...Can take a while...
Building image-local-fedora...
STEP 1/2: FROM fedora:39
Resolving %!q(<nil>) to docker.io (enforced by caller)
Trying to pull docker.io/library/fedora:39...
Getting image source signatures
Copying blob sha256:22bb2152dc6386a1d2269ed00e37f29db25a6003edd92e1e785aace8b93f657c
Copying config sha256:40a32ce358f786e152609d399c331d807270e10783a70bfaaf654ac32fbb72a5
Writing manifest to image destination
STEP 2/2: RUN dnf install -y vim
exec container process `/bin/sh`: Exec format error
Error:building at STEP "RUN dnf install -y vim": while running runtime: exit status 1

Relevant log output

Uploading the build context from C:\Users\podmanqe\fedora_images...Can take a while...
Building image-local-fedora...
STEP 1/2: FROM fedora:39
Resolving %!q(<nil>) to docker.io (enforced by caller)
Trying to pull docker.io/library/fedora:39...
Getting image source signatures
Copying blob sha256:22bb2152dc6386a1d2269ed00e37f29db25a6003edd92e1e785aace8b93f657c
Copying config sha256:40a32ce358f786e152609d399c331d807270e10783a70bfaaf654ac32fbb72a5
Writing manifest to image destination
STEP 2/2: RUN dnf install -y vim
exec container process `/bin/sh`: Exec format error
Error:building at STEP "RUN dnf install -y vim": while running runtime: exit status 1

Additional context

No response

odockal avatar Apr 29 '24 15:04 odockal

could you please be sure to clean all the build cache before, I saw some bugs using buildah sometimes

podman system prune

benoitf avatar Apr 29 '24 20:04 benoitf

Does not seem like the case.

odockal avatar Apr 29 '24 20:04 odockal

could you please be sure to clean all the build cache before, I saw some bugs using buildah sometimes

podman system prune

Looks like this is happening too on our "other extension" side. There is an issue posted regarding another error @odockal got.

When I did podman machine reset and recreated the machine it looks to have fixed it.

cdrage avatar Apr 30 '24 00:04 cdrage

I just tried on a macOS amd64 and it works

https://github.com/containers/podman-desktop/assets/436777/12942213-978e-4613-a908-39db418a9498

(it says aarch64 while I'm on a amd64 system)

benoitf avatar Apr 30 '24 13:04 benoitf

@odockal looks like it may be this issue: https://github.com/containers/podman/issues/19961 as I was able to replicate it myself.

macOS and Linux is it working fine.

Windows is unfortunately having issues building an arm image. It looks like a caching issue as per the last comment.

Only way is to reset the podman machine and try again it seems.

cdrage avatar Apr 30 '24 14:04 cdrage

in all case issue is not in podman desktop codebase so I would not make it as a blocker for 1.10.x

benoitf avatar Apr 30 '24 14:04 benoitf

@cdrage @benoitf I believe that you are right. It might be out of control of podman desktop. although, if people will start build cross-platform images on windows, they gonna hit this. I have never managed on windows amd64 host to build image with target arch64 platform nor via podman desktop nor using cli.

Update: I am not saying this is blocking release, though.

odockal avatar Apr 30 '24 14:04 odockal

Containerfile:

FROM fedora:39
RUN arch

cli command: podman build -t fedora-arch --platform=linux/amd64 .

Result is the same for pd and podman cli: Error: building at STEP "RUN arch": while running runtime: exit status 1

odockal avatar Apr 30 '24 14:04 odockal

@cdrage @benoitf The workaround suggested in the last comment make it work!

odockal avatar Apr 30 '24 14:04 odockal

Workaround:

podman machine ssh
curl https://raw.githubusercontent.com/qemu/qemu/master/scripts/qemu-binfmt-conf.sh > qemu-binfmt-conf.sh
chmod +x qemu-binfmt-conf.sh
sudo mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
sudo ./qemu-binfmt-conf.sh --qemu-suffix "-static" --qemu-path "/usr/bin" -p yes
exit
podman build -t fedora-arch --platform=linux/arm64 .
STEP 1/2: FROM fedora:39
STEP 2/2: RUN arch
aarch64
COMMIT fedora-arch
--> 0b4b09c0e454
Successfully tagged localhost/fedora-arch:latest
0b4b09c0e45452807989881064fa4b94741246e2bc39ab29a91e38b2700256f7

odockal avatar Apr 30 '24 14:04 odockal

OK so definitely a podman issue. We might ask them to see if they can fix it in the podman machine

benoitf avatar Apr 30 '24 16:04 benoitf

I think it requires fixes but only in the machine

benoitf avatar Apr 30 '24 16:04 benoitf

https://github.com/containers/podman-machine-wsl-os/blob/main/.cirrus.yml probably a patch there

benoitf avatar Apr 30 '24 16:04 benoitf

Adding os/Windows label to the issue as it's windows specific ( on macOS it works as expected)

benoitf avatar Apr 30 '24 16:04 benoitf

removing 1.10.1 milestone and created https://github.com/containers/podman/issues/22883

benoitf avatar Apr 30 '24 20:04 benoitf