Mac M1 上的 Docker 给出 : "The requested image' s platform (linux/amd64) does not match the detected host platform"

标签 docker docker-compose arm apple-m1

我想为 Ganache 运行一个 docker 容器在我的 MacBook M1 上,但收到以下错误:

The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
在这一行之后,没有其他任何事情发生并且整个过程都卡住了,尽管根据事件监视器,qemu-system-aarch64 在 100% CPU 上运行,直到我按下 Ctrl-C。
我的 docker 文件来自这个存储库:https://github.com/unlock-protocol/unlock/blob/master/docker/docker-compose.override.yml .在那里运行相同的问题后,我尝试隔离根本原因,并提出了会遇到相同错误的最小设置。
这是 docker-compose up --build 的输出:
Building ganache
Sending build context to Docker daemon  196.6kB
Step 1/17 : FROM trufflesuite/ganache-cli:v6.9.1
 ---> 40b011a5f8e5
Step 2/17 : LABEL Unlock <ops@unlock-protocol.com>
 ---> Using cache
 ---> aad8a72dac4e
Step 3/17 : RUN apk add --no-cache git openssh bash
 ---> Using cache
 ---> 4ca6312438bd
Step 4/17 : RUN apk add --no-cache   python   python-dev   py-pip   build-base   && pip install virtualenv
 ---> Using cache
 ---> 0be290f541ed
Step 5/17 : RUN npm install -g npm@6.4.1
 ---> Using cache
 ---> d906d229a768
Step 6/17 : RUN npm install -g yarn
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
 ---> Running in 991c1d804fdf
docker-compose.yml:
version: '3.2'
services:
  ganache:
    restart: always
    build:
      context: ./development
      dockerfile: ganache.dockerfile
    env_file: ../.env.dev.local
    ports:
      - 8545:8545

  ganache-standup:
    image: ganache-standup
    build:
      context: ./development
      dockerfile: ganache.dockerfile
    env_file: ../.env.dev.local
    entrypoint: ['node', '/standup/prepare-ganache-for-unlock.js']
    depends_on:
      - ganache
ganache.dockerfile:
ganache.dockerfile 可以在这里找到:https://github.com/unlock-protocol/unlock/blob/master/docker/development/ganache.dockerfile
在带有 Intel 处理器的旧 iMac 上运行整个项目工作正常。

最佳答案

如果您计划在您的笔记本电脑中运行该镜像,则需要为该特定机器的 CPU 架构构建它。您可以提供--platform docker build(甚至docker-compose)的选项来定义要为其构建镜像的目标平台。
例如:

docker build --platform linux/arm64  .

关于Mac M1 上的 Docker 给出 : "The requested image' s platform (linux/amd64) does not match the detected host platform",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69054921/

相关文章:

gcc - 如何将 GCC LTO 与不同优化的目标文件一起使用?

docker - 使用卷时无法在主机上使用 mysql 套接字

docker - vscode 中的断点 (Win 10) "unverified"并且在 Linux Docker 容器 (Hyper-V) 中远程调试 Go 应用程序时未命中

python - 以编程方式在 dockerized apache Airflow python 操作符内创建 SSH 隧道

git - 使用 Docker 容器非 root 用户克隆 GitHub 私有(private)存储库?

optimization - GCC -mthumb 反对 -marm

embedded - 寻求32位板用于嵌入式开发

docker - 将CI Runner连接到Docker网络

docker - 如何列出所有容器的暴露端口?

docker - coreos 与 Triton 相比如何?