Docker 是怎么知道要模拟 arm 架构的?

How did Docker know to emulate arm architecture?

这对我来说是一个巨大的惊喜:

今天,使用 Docker For Mac (18.03.1-ce-mac65),我 运行 Debian Stretch 镜像。在图像中,我使用 mount 安装了最新的 Raspbian 拉伸图像 (2018-04-18-raspbian-stretch-lite)。然后我将 chroot 用于这个挂载的 Raspbian 文件系统。

这就是它变得奇怪的地方。我能够使用 apt(无需任何特殊修改)将软件安装到这个挂载的文件系统中。

运行:

dpkg --print-architecture

返回:armfh 我安装的软件 (vim) 运行得非常棒

我什至能够使用 gcc 和 运行 编译一个简单的程序。

但是,我需要知道!这怎么可能?

根据Docker

Docker for Mac provides binfmt_misc multi architecture support, so you can run containers for different Linux architectures, such as arm, mips, ppc64le, and even s390x.

编辑

在 Linux 上,您可以安装 qemu-user-static,然后按照 this git 存储库获得跨架构支持!