如何在 arm64 主机平台上运行 amd64 docker 镜像 [英] how to run amd64 docker images on arm64 host platform

查看:286
本文介绍了如何在 arm64 主机平台上运行 amd64 docker 镜像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台 m1 mac,我正在尝试在基于 arm64 的主机平台上运行基于 amd64 的 docker 映像.但是,当我尝试这样做时(使用 docker run),我收到以下错误:

I have an m1 mac and I am trying to run a amd64 based docker image on my arm64 based host platform. However, when I try to do so (with docker run) I get the following error:

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested. 

当我尝试添加标签 --platform linux/amd64 时,错误消息没有出现,但我似乎无法进入相关的 shell 和 docker ps -a 显示容器在启动时立即退出.有谁知道在特定情况下我如何在我的机器上运行这个精确的图像/如何使 --platform 标签工作?

When I try adding the tag --platform linux/amd64 the error message doesn't appear, but I can't seem to go into the relevant shell and docker ps -a shows that the container is immediately exited upon starting. Would anyone know how I can run this exact image on my machine given the circumstances/how to make the --platform tag work?

推荐答案

使用 --platform 是正确的.在我的 M1 Mac 上,我能够从 Docker Hub 运行 arm64 和 amd64 版本的 Ubuntu 映像.uname 提供的机器硬件名称证明了这一点.

Using --platform is correct. On my M1 Mac I'm able to run both arm64 and amd64 versions of the Ubuntu image from Docker Hub. The machine hardware name provided by uname proves it.

# docker run --rm -ti --platform linux/arm/v7 ubuntu:latest uname -m
armv7l

# docker run --rm -ti --platform linux/amd64 ubuntu:latest uname -m
x86_64

Rosetta2 仿真启用了运行 amd64 图像,如此处.

Running amd64 images is enabled by Rosetta2 emulation, as indicated here.

并非所有映像都适用于 ARM64 架构.您可以添加 --platform linux/amd64 以在仿真下运行 Intel 映像.

Not all images are available for ARM64 architecture. You can add --platform linux/amd64 to run an Intel image under emulation.

如果容器立即退出,则说明您使用的特定容器有问题.

If the container is exiting immediately, that's a problem with the specific container you're using.

这篇关于如何在 arm64 主机平台上运行 amd64 docker 镜像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆