2

I'm trying to run an amd64 UBI9 image on Apple silicon with Podman. Podman provides a Fedora CoreOS VM to run containers in. It allows for installing qemu binaries to run "foreign architecture" containers.

Problem is, the architecture of the UBI9 images is x86_64-v2 and the qemu-x86_64-static binary in the Fedora CoreOS VM does not support that (yet?).

That means that running said image results in an error:

➜ podman build -f Containerfile --platform linux/amd64 -t mycontainer:0.3 .
STEP 1/7: FROM registry.access.redhat.com/ubi9/ubi-minimal:latest
STEP 2/7: RUN microdnf install -y python3 python3-pip
Fatal glibc error: CPU does not support x86-64-v2
Error: error building at STEP "RUN microdnf install -y python3 python3-pip": error while running runtime: exit status 127

From what I understand, setting an environment variable called QEMU_CPU to max in the VM might solve this, but I'm unsure how and where to set that variable for it to be picked up by the podman processes.

Anyone solved this already?

(I could have put this on the MacOS site, the Superuser site and stackoverflow.com, I guess, but I think it fits here best because of the specific knowledge required.)

SOLVED: For posterity: I ended up filing a bug for this and this was fixed my making the Fedora CoreOS image used on MacOS to run containers use a different compile flag for the qemu library that emulates x86_64 on arm64.

Bug: https://github.com/containers/podman/issues/15456

wzzrd
  • 10,409
  • 2
  • 35
  • 47
  • For posterity: I ended up filing a bug for this and this was fixed my making the Fedora CoreOS image used on MacOS to run containers use a different compile flag for the qemu library that emulates x86_64 on arm64. Bug: https://github.com/containers/podman/issues/15456 – wzzrd Mar 16 '23 at 11:30

2 Answers2

0

Your command, you specify 'amd64', it won't work... You run a ARM processor. And the VM is aware of that. You can't run a x86 image on a ARM.

Or you could run:

podman run -it --arch=arm64 registry.access.redhat.com/ubi9/ubi:9.0.0-1604 /bin/bash

I am not sure about this one TBH. I think it does ''emulation'' but really not sure. But I know the container will start....

P.S: Do not forget that not all containers are built for Apple Silicon (ARM) and this apply to packages as well

yield
  • 771
  • 1
  • 9
  • 24
  • 1
    It can definitely work: Podman and Docker provide a qemu-x86_64 binary that can translate system call and interpret te executable format of foreign architectures (not an expert, but that’s roughly what it does). Problem is that the shipped binary is not compatible with the x86_64-v2 format of RHEL9 – wzzrd Aug 25 '22 at 15:25
  • RHEL 8: `$ podman run --platform linux/amd64 -it registry.access.redhat.com/ubi8/ubi` works ok on my MBP. RHEL 9, not so much. – Jari Turkia Feb 07 '23 at 12:55
0

I ran into the same problem but I was using colima. Actually both colima and podman use QEMU hypervisor under the hood. I did some digging and for colima it's realy simple you just have to instruct a different cpu-type for QEMU:

colima start -cpu 4 -memory 8 --cpu-type max

That 'max' instructs QEMU to give the emulated cpu the same capabilities of the host machine cpu. And Silicon processors supports x86_64_v2. You can try with docker-desktop and you will see it working. If you can change to colima I would advise you to do so if not keep reading :)

Because you are using podman, probably podman is using defaults similar to colima and that's why it doens't work. I search in the official documentation and I think they don't provide such flag (https://docs.podman.io/en/latest/markdown/podman-machine-init.1.html) but I think you can tweek QEMU configuration files that should be somewhere around here:

~/.config/containers/podman/machine/qemu

See example here: https://github.com/containers/podman/issues/10577#issuecomment-855400042

Where the guy haves 'cortex-a57' you should have 'max'.