Can't run example image on raspbian buster

I downloaded docker on a windows laptop and a raspberry pi 3 (with the latest version of raspbian buster).

I’m able to get hello-world and nginx working fine on both devices, but when I made and uploaded the example image on https://docs.docker.com/get-started/part2/ to my personal repository, when i try to run it on the pi I get the error message

standard_init_linux.go:211: exec user process caused “exec format error”

I confirmed that this works as intended on windows. What is the issue with running it on the raspbian docker?

There may be an issue with the instruction set architecture assumed by the image(s) and/or applications you are attempting to use. The Pi runs on an ARM instruction set, while most examples in the wild assume the image is running on x86_64. Further, most examples assume you’re running on Linux on x86_64.

1 Like

yeah, this seems to be the problem. If I copy all my files to the pi and build it there, the example image seems to work.

Is there any way to build the image so that it works on both devices, without copying everything over to the pi and building it there?

edit: i did some research and came accross the experimental feature buildx, which seems to solve my problem.

Yes, buildx exactly. The experimental buildx may be suitable for your purposes. Docker recently announced a partnership with the folks behind the ARM architecture, and multi-platform builds and images were announced at close to the same time. So long as you have a sufficiently recent engine, you may be able to build images suitable for the pi or for out of the box linux x86_64, etc.

For those not yet familiar with buildx, you can gather some information here.