可以在 Windows 上的 Docker 中运行 ARM/rpi 映像,但不能在 linux 上运行

可以在 Windows 上的 Docker 中运行 ARM/rpi 映像,但不能在 linux 上运行

问题描述:

我能够在 Windows(64 位)上的 Docker 中运行 ARM 映像(例如 hypriot/rpi-node),但在我尝试过的所有 linux x86/64 机器(Debian、CoreOS、Alpine 等)中我收到以下错误 - 这对我来说很有意义,但我不明白为什么它会在 Windows 上的 Docker 中运行,我想知道我是否错过了使用 x86 机器作为 ARM 映像构建服务器的机会(即.在谷歌/aws 云/天蓝色).我有什么想法可以做到吗?

I'm able to run the ARM images (eg. hypriot/rpi-node) in Docker on Windows (64bit), but in all linux x86/64 machines I've tried (Debian, CoreOS, Alpine etc) I get the following error - which makes sense to me but I dont get why it'd run in Docker on Windows then, and I wonder whether I'm missing some opportunity to use an x86 machine as a build server for ARM images (ie. the in google/aws cloud/azure). Any ideas how I might be able to?

docker run -ti hypriot/rpi-node ls
standard_init_linux.go:175: exec user process caused "exec format error"

Docker for windows(和 docker for mac)都使用 linux vm 来托管容器.但是,他们使用的 linux vm 和您的 linux 机器之间的区别在于,他们的 VM 有一个名为 binfmt_misc 设置的内核系统,以便在遇到外部架构的二进制文件时调用 qemu (https://github.com/59d2030000000d3c83362d241e54142323ca/pkg/binfmt/etc/binfmt.d/00_linuxkit.conf"binfmt/etc/binfmt.d/00_linuxkit.conf )

Docker for windows (and docker for mac) both use a linux vm to host containers. However, the difference between the linux vm they use and your linux machines is the fact that their VM has a kernel system called binfmt_misc setup to call qemu whenever it encounters a binary for a foreign architecture (https://github.com/linuxkit/linuxkit/blob/1c552f7a9db7f0660d3c83362d241e54142323ca/pkg/binfmt/etc/binfmt.d/00_linuxkit.conf )

如果您要适当地配置您的 linux 机器,它可以用作 ARM 映像的构建服务器.谷歌 qemu-user-static 关于如何设置它的一些想法.

If you were to configure your linux machine appropriately, it could be used as a build server for ARM images. Google qemu-user-static for some ideas of how to set it up.

请注意,linuxkit vm 使用F"标志,这在配置典型的 linux 环境时似乎不是标准的.没有它,您需要将 qemu 二进制文件放入容器中.我不确定为什么在更多地方使用F"不是标准做法(似乎确实有一个 debian 错误这样做 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=868030 )

Note that the linuxkit vm uses the 'F' flag which doesn't seem to be standard when configuring a typical linux environment. Without it, you need to put the qemu binary inside the container. I'm not sure why it isn't standard practice to use 'F' in more places (there does seem to be a debian bug to do so https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=868030 )