I am building a linux/arm/v7 image from Windows 10 to be run on a Raspberry Pi running a 32 bit OS.
Dockerfile
FROM nginx:1.19.8-alpine
CMD nginx -g 'daemon off;'
Build and push
On Windows, I run:
docker buildx build --platform linux/arm/v7 -t harvzor/nginx-multi-arch-cross-compile --push .
Running docker inspect image harvzor/nginx-multi-arch-cross-compile on the built image produces:
[
{
// ...
"Architecture": "arm",
"Os": "linux",
// ...
}
]
Docker Hub identifies the image as arm based.
https://hub.docker.com/repository/docker/harvzor/nginx-multi-arch-cross-compile
Pull and run (error!)
I then pull down that same image on the Raspberry Pi and try running it, this is the output:
$ docker run harvzor/nginx-multi-arch-cross-compile
standard_init_linux.go:211: exec user process caused "exec format error"
failed to resize tty, using default size
Details
My image is based off of nginx:1.19.8-alpine, which has a linux/arm/v7 OS/ARCH.
Inspecting buildx on Windows produces:
$ docker buildx inspect
Name: default
Driver: docker
Nodes:
Name: default
Endpoint: default
Status: running
Platforms: linux/amd64, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/arm/v7, linux/arm/v6
If I try running this image on Windows, it runs fine (though I think it should not since it is built for arm).
Windows Docker versions
$ docker -v
Docker version 19.03.13, build 4484c46d9d
docker buildx version
github.com/docker/buildx v0.4.2-tp-docker fb7b670b764764dc4716df3eba07ffdae4cc47b2
Questions
What am I doing wrong? Why does the image work on Windows and not the target platform?