简体   繁体   中英

docker in macOS running arm64 on amd64

While testing a specific version of the vault project on a macOS ( version 10.13.6 ), using Docker 18.06.10-ce-mac73 I created this Dockerfile:

FROM ubuntu
RUN apt-get update && apt-get install -y --no-install-recommends -q curl build-essential ca-certificates git net-tools netcat unzip jq
WORKDIR /vault
RUN mkdir -p /vault/bin && \
    cd /vault/bin && \
    curl -o vault.zip -sL https://releases.hashicorp.com/vault/0.9.0/vault_0.9.0_linux_arm64.zip && unzip vault.zip
ENV PATH="/vault/bin:${PATH}"
ENTRYPOINT /bin/bash

The container came up, I was available to use it and run all the required tests, the only thing that I was noticing is that before the output of all the commands, I was getting something like this:

root@d2abe7afe964:/vault/bin# vault --version
Unknown host QEMU_IFLA type: 40
Unknown host QEMU_IFLA type: 41
Unknown host QEMU_IFLA type: 40
Unknown host QEMU_IFLA type: 41
Unknown QEMU_IFLA_INFO_KIND ipip
Unknown host QEMU_IFLA type: 40
Unknown host QEMU_IFLA type: 41
Unknown QEMU_IFLA_INFO_KIND ip6tnl
Unknown host QEMU_IFLA type: 40
Unknown host QEMU_IFLA type: 41
Vault v0.9.0 ('bdac1854478538052ba5b7ec9a9ec688d35a3335')

A colleague using a Linux(Ubuntu) couldn't run the vault command, the error he was getting was:

exec error command failed

After checking more in the detail the issue was that the Dockerfile was using vault_0.9.0_linux_arm64.zip instead of vault_0.9.0_linux_amd64.zip . By mistake, the binary for the arm64 was being used instead of the required amd64 the thing that surprised us is that within the macOS environment was working.

Therefore would like to know more in detail why this happens, and if there is a way to run the containers in a "strict" or more Linux "like" when required?

Because the Docker on MacOS (your machine) comes with a Linux virtual machine (Docker container need some features of Linux kernel to run, so it cannot run on MacOS alone). That Linux VM has been configured with QEMU and binfmt_misc, so it can run the arm64 container. Meanwhile, your friend machine has Docker running on his native Linux (not via VM), and his Linux is not configured enough to run arm64 container.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM