Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Podman can't run command on M1 with container built on X86 #12144

Closed
cscetbon opened this issue Oct 31, 2021 · 11 comments
Closed

Podman can't run command on M1 with container built on X86 #12144

cscetbon opened this issue Oct 31, 2021 · 11 comments
Assignees
Labels
kind/feature Categorizes issue or PR as related to a new feature. stale-issue

Comments

@cscetbon
Copy link

Docker can run on Apple M1 a container built on X86 but Podman can't

$ docker --version
Docker version 20.10.8, build 3967b7d

$ docker run -ti senseyeio/alpine-aws-cli echo ok
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
ok
$ podman --version
podman version 3.4.1

$ podman machine list 
NAME                     VM TYPE     CREATED         LAST UP            CPUS        MEMORY      DISK SIZE
podman-machine-default*  qemu        34 minutes ago  Currently running  1           2.147GB     10.74GB

$ podman run -ti senseyeio/alpine-aws-cli echo ok
{"msg":"exec container process `/bin/echo`: Exec format error","level":"error","time":"2021-10-31T01:54:47.000542236Z"
@rhatdan
Copy link
Member

rhatdan commented Oct 31, 2021

@baude If we install qemu-user-static on the Fedora CoreOS, this would just work, although would be slow.

@afbjorklund

This comment has been minimized.

@cscetbon
Copy link
Author

@baude If we install qemu-user-static on the Fedora CoreOS, this would just work, although would be slow.

@rhatdan, do you mean there is a way to be more efficient or that's just what it is ? I suppose we can also mimic what is done by docker ?

@afbjorklund
Copy link
Contributor

afbjorklund commented Oct 31, 2021

Docker uses the same qemu-user-static, and the same binfmt_misc feature of Linux in order to do this.

$ docker run -it arm64v8/alpine
WARNING: The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64) and no specific platform was requested
standard_init_linux.go:228: exec user process caused: exec format error
$ sudo apt install qemu-user-static
...
$ docker run -it arm64v8/alpine
WARNING: The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64) and no specific platform was requested
/ # exit

It is statically linked, so it works the same inside the container as it does in Linux outside the container.

$ podman machine init
Downloading VM image: fedora-coreos-34.20211016.2.1-qemu.x86_64.qcow2.xz: done  
Extracting compressed file
$ podman machine start
INFO[0000] waiting for clients...                       
INFO[0000] listening tcp://0.0.0.0:7777                 
INFO[0000] new connection from @ to /run/user/1000/podman/qemu_podman-machine-default.sock 
Waiting for VM ...
Machine "podman-machine-default" started successfully
$ podman-remote run -it amd64/alpine
Resolving "amd64/alpine" using unqualified-search registries (/etc/containers/registries.conf.d/999-podman-machine.conf)
Trying to pull docker.io/amd64/alpine:latest...
Getting image source signatures
Copying blob sha256:a0d0a0d46f8b52473982a3c466318f479767577551a53ffc9074c9fa7035982e
Copying config sha256:14119a10abf4669e8cdbdff324a9f9605d99697215a0d21c360fe8dfa8471bab
Writing manifest to image destination
Storing signatures
/ # exit
$ podman-remote run -it arm64v8/alpine
Resolving "arm64v8/alpine" using unqualified-search registries (/etc/containers/registries.conf.d/999-podman-machine.conf)
Trying to pull docker.io/arm64v8/alpine:latest...
Getting image source signatures
Copying blob sha256:552d1f2373af9bfe12033568ebbfb0ccbb0de11279f9a415a29207e264d7f4d9
Copying blob sha256:552d1f2373af9bfe12033568ebbfb0ccbb0de11279f9a415a29207e264d7f4d9
Copying config sha256:bb3de5531c18f185667b0be0e400ab24aa40f4440093de82baf4072e14af3b84
Writing manifest to image destination
Storing signatures
{"msg":"exec container process `/bin/sh`: Exec format error","level":"error","time":"2021-10-31T17:29:30.000710590Z"}

podman machine ssh sudo rpm-ostree install qemu-user-static
podman machine ssh sudo systemctl reboot

$ podman-remote run -it arm64v8/alpine
/ # exit

@cscetbon
Copy link
Author

Then I guess it's the way to go and easy enough to implement 🙌

@afbjorklund
Copy link
Contributor

afbjorklund commented Oct 31, 2021

Then I guess it's the way to go and easy enough to implement raised_hands

Note that you get much better performance, by selecting the same arch...

The "multi-arch" images (manifests) makes this easy, so that it gets the same name.
I used the arch-specific name above, just to force a mismatch for the demonstration.

https://github.com/docker-library/official-images#architectures-other-than-amd64

@cscetbon
Copy link
Author

Yeah yeah I get it. Sometimes images are not available on one architecture and it's easier to just use them instead of having to build one for the arm64 architecture, especially for non production images.

@afbjorklund
Copy link
Contributor

Probably one could have saved some space in the image, if not all binaries were in the same package ?

Most users are only interested in qemu-aarch64-static and qemu-x86_64-static, not the other 32 arch.

@vrothberg vrothberg added the kind/feature Categorizes issue or PR as related to a new feature. label Nov 17, 2021
@github-actions
Copy link

A friendly reminder that this issue had no activity for 30 days.

@rhatdan
Copy link
Member

rhatdan commented Dec 18, 2021

This seems like more of a discussion then an actual issue, unless you want us to ship qemu-user-static inside of the fedora coreos?

@github-actions
Copy link

A friendly reminder that this issue had no activity for 30 days.

@containers containers locked and limited conversation to collaborators Jan 18, 2022
@rhatdan rhatdan converted this issue into discussion #12899 Jan 18, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
kind/feature Categorizes issue or PR as related to a new feature. stale-issue
Projects
None yet
Development

No branches or pull requests

6 participants