Skip to content
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

Can't run quemu-static on arm64v8/ubuntu:20.04 #158

Open
Corallo opened this issue Dec 2, 2021 · 4 comments
Open

Can't run quemu-static on arm64v8/ubuntu:20.04 #158

Corallo opened this issue Dec 2, 2021 · 4 comments

Comments

@Corallo
Copy link

Corallo commented Dec 2, 2021

Description:
I am trying to reproduce the first example of this simple guide:
https://www.balena.io/blog/building-arm-containers-on-any-x86-machine-even-dockerhub/

on an arm64v8/ubuntu:20.04 image.

But I get an incompatible ELF error when building

Step tu reproduce
Docker file:

FROM arm64v8/ubuntu:20.04 as build-base-arm 
COPY --from=multiarch/qemu-user-static:x86_64-arm-6.1.0-8 /usr/bin/qemu-arm-static /usr/bin/qemu-arm-static 
RUN [ "/usr/bin/qemu-arm-static", "/bin/echo", "Hello from ARM container" ]

On shell:
docker build .

Describe the results you received:
---> [Warning] The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64) and no specific platform was requested ---> Running in 8fb3cc786c60 qemu-arm-static: /bin/echo: Invalid ELF image for this architecture

Describe the results you expected:
Hello, world!

Environment:
I am on a fresh Ubuntu:20:04

Output of docker version, podman version or singularity version

[255] angelod@lap5cg1375wnh> docker version                                                                                                                                  ~/Desktop/arm64-docker/test
Client: Docker Engine - Community
 Version:           20.10.10
 API version:       1.41
 Go version:        go1.16.9
 Git commit:        b485636
 Built:             Mon Oct 25 07:42:59 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.10
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.9
  Git commit:       e2f740d
  Built:            Mon Oct 25 07:41:08 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.11
  GitCommit:        5b46e404f6b9f661a205e28d59c982d3634148f8
 runc:
  Version:          1.0.2
  GitCommit:        v1.0.2-0-g52b36a2
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0


Additional information optionally:
I don't have podman/singularity

@martin-g
Copy link

martin-g commented Dec 2, 2021

You need to run docker run -it --rm --privileged multiarch/qemu-user-static --credential yes --persistent yes first.
See https://martin-grigorov.medium.com/building-linux-packages-for-different-cpu-architectures-with-docker-and-qemu-d29e4ebc9fa5

@Corallo
Copy link
Author

Corallo commented Dec 2, 2021

You need to run docker run -it --rm --privileged multiarch/qemu-user-static --credential yes --persistent yes first. See https://martin-grigorov.medium.com/building-linux-packages-for-different-cpu-architectures-with-docker-and-qemu-d29e4ebc9fa5

I tried to follow the instructions in your article, but it seems there's still something missinig:
after docker run -it --rm --privileged multiarch/qemu-user-static --credential yes --persistent yes, I get the expected output, several Setting /usr/bin/qemu-...-static as binfmt interpreter for ....
However, when I run:
docker run -it --rm arm64v8/centos:8 uname -m
I get

WARNING: The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64) and no specific platform was requested
aarch64

which is unexpected

@martin-g
Copy link

martin-g commented Dec 3, 2021

To avoid the warning you need to pass --platform linux/arm64:

docker run --platform linux/arm64 -it --rm arm64v8/centos:8 uname -m

@Corallo
Copy link
Author

Corallo commented Dec 3, 2021

I see, the warning was just saying that the docker image and the host machine have different architecture, the actuall error disappeared after running your command:
docker run -it --rm --privileged multiarch/qemu-user-static --credential yes --persistent yes
Thanks a lot for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants