-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[windows/wsl] binfmt does not work in default machine #19961
Comments
A friendly reminder that this issue had no activity for 30 days. |
A friendly reminder that this issue had no activity for 30 days. |
I've been looking into multi-arch support on Windows Podman for a couple days now, and unfortunately the resources on this is sparse as it doesn't seem to be a common dev environment. From what I've gathered though, this seems to be an issue with the binfmt_misc configuration in the podman machine. The immediate fixes for this are either using the multiarch/qemu-user-static container: $ podman run --rm --privileged multiarch/qemu-user-static --reset -p yes or, essentially what it's doing is running the $ 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 ./qemu-binfmt-conf.sh --qemu-suffix "-static" --qemu-path "/usr/bin" -p yes However, this doesn't persist across restarts. If you restart your computer or do a Unfortunately I've not found a solution that feels more proper and permanent than this. From what I've seen, there are mentions of None of this is particularly well documented or discussed anywhere when it comes to Windows so any insight would be appreciated. [Edit] I missed the end and I see that [Edit] [Edit] Okay disregard most of this. I think the latest version fixes the issues for building to say ARM, but not for running for ARM. I'm getting the same error when running: $ podman run --rm -it --platform linux/arm docker.io/library/hello-world Notably the fix mentioned didn't seem to work for me either. [Edit] $ podman run --rm -it --platform linux/arm docker.io/library/hello-world and
with the following Containerfile: FROM oraclelinux:8
RUN echo "Hello world"
CMD ["echo", "Hello world"] [Edit] I've tried removing the default machine and reinitializing it like six times in a row now after it wasn't working and now it is consistently working without changes. I'm kind of at a loss at what makes it work and what doesn't honestly. |
Going to post this as a new comment because I think I got lost in the weeds in the last one. I think the weird inconsistencies I was having was due to either something persisting between different podman machines or cacheing of some kind. After it was working consistently, it started no longer working consistently, and since I can't seem to replicate it in either way confidently, just going to ignore it. I do notice in the default podman machine (now on Fedora 39), there is a mount defined in
Concerning
Ultimately, the only valid temporary fixes I found for both building and running multi-architecture containers on Windows is using the multiarch/qemu-user-static container or the manual commands listed initially. I think technically this should be preceeded with a binfmt_misc mount, so it should look something like this: $ 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 Again, this only works so long as the machine stays up. If it doesn't, you will need to remount and rerun the configuration script. Or if you're using the container method, rerun the container. |
We're experiencing this as well on the Podman Desktop side. Looks to be related to the qemu as per @Aetylus 's awesome investigation. Using the:
Looks to mitigate the problem for now (until you restart the podman machine). |
Only for Documentation, another way of fixing binfmt mountings Before: podman run --rm -it --platform linux/arm docker.io/library/hello-world
{"msg":"exec container process `/hello`: Exec format error","level":"error","time":"2024-09-14T09:36:27.872578Z"} SSH in your machine by podman machine ssh, or wsl -d... Fixing the binfmt mount options by masking the auto generated ubuntu services: systemctl mask proc-sys-fs-binfmt_misc.mount
systemctl mask proc-sys-fs-binfmt_misc.automount
systemctl edit systemd-binfmt.service In the open VI Add the following lines: [Unit]
ConditionPathIsMountPoint=
[Service]
ExecStartPre=-mount --onlyonce /proc/sys/fs/binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc -v
Now on start of machine the proc mount should manual be valid. Now the command will work: podman run --rm -it --platform linux/arm docker.io/library/hello-world Please report/comment me if anyone has a simply or cleaner solution, and if this help you. PS: I will not blame podman for this - I think this is a incompatibility of the used ubuntu images vs. WSL. PS2: As Alternative to resolv DNS failure by adding generateResolvConf = false -- in current WSL you can setup dnsProxy=false in your %USER%/.wslconfig file before doing a podman machine init. |
Here is a simple systemd service to run the script wehen the podman-machine starts up: You will need to have the qemu-binfmt-conf.sh script downloaded. ( /etc/systemd/system/setupMultiArch.service:
/root/setup.sh:
Then run as root: systemctl enable --now setupMultiArch.service |
Issue Description
The default machine (WSL 2, Fedora) created during installation of podman for windows has broken binfmt support.
Steps to reproduce the issue
Describe the results you received
Describe the results you expected
The default output of the
hello-world
image (c.f. https://hub.docker.com/_/hello-world, section "Example Output")podman info output
Podman in a container
Yes
Privileged Or Rootless
Privileged
Upstream Latest Release
Yes
Additional environment details
Additional information
The problem can be worked around by:
systemd-udev
, so thatsystemd-binfmt
andsystemd-binfmt.service
are available:sudo dnf install systemd-udev
sudo sh -c 'echo :WSLInterop:M::MZ::/init:PF > /usr/lib/binfmt.d/WSLInterop.conf'
systemd-binfmt
service to apply changes:sudo systemctl restart systemd-binfmt.service
The text was updated successfully, but these errors were encountered: