Docker buildx mulitarch armv6

2k Views Asked by At

What I need:

A test container on a x86_64 machine for a raspberry pi zero, which works with qemu emulation for armv6l.

What I've got so far:

A Dockerfile with a test code

FROM python:3.7.9

COPY hello.py ./

CMD [ "python3", "./hello.py" ]

The image is built with this command:

docker buildx build --platform linux/arm/v6 -t test/hello --push .

After it has been uploaded and built for linux/arm/v6 I try to run it with this command:

docker run --platform=linux/arm/v6 --rm -t test/hello uname -mpi 
Output: armv7l unknown unknown

I have set up qemu and binfmt like they say on their github page: https://github.com/docker/buildx#building-multi-platform-images

I do not understand why the output is armv7l, because I did everything to make an armv6l image. I do not know if I need to make adjustments to docker or qemu itself. I am quite new to the buildx system of docker and how to emulate the container under qemu so if anyone could help me out with this problem I would be very grateful.

EDIT:

Thanks to Peter the container is know forced to use armv6l.

docker run -e QEMU_CPU=arm1176 --platform=linux/arm/v6 --rm -t test/hello uname -mpi
Output: armv6l unknown unknown
1

There are 1 best solutions below

0
On BEST ANSWER

uname is telling you 'armv7l' because you have not specified to QEMU that it should emulate any particular CPU type, and its default is "all the features we can emulate".

This should not be a problem, because all software that can run on a v6 CPU will run on a v7 CPU. (That's why QEMU's default is what it is: it means that in general guest programs will all just work.)

I'm not familiar with docker, but I suspect that its 'platform' argument is simply configuring what the code inside the container is built to run on. So you have a container full of v6 binaries, which will run on either a v6 CPU or a v7 one.

If you really need to force QEMU to emulate a v6 CPU and not a v7 one, you can set the environment variable QEMU_CPU to 'arm1176', which will make QEMU emulate that specific CPU.