在ARM64主机(Apple Silicon Machine)上运行AMD64 Docker-In-Docker(DIND)容器

发布于 2025-01-21 18:16:57 字数 2059 浏览 2 评论 0原文

我正在尝试在ARM64主机(Apple Silicon)上运行AMD64 Docker-In-Docker(DIND)容器,因为在此DIND上运行的某些图像仅为AMD64(例如MySQL-5.7)。

在带有Apple芯片的Mac上运行此命令:

docker run --platform linux/amd64 --privileged --name dind docker:dind

错误消息获取:

......
time="2022-04-16T04:28:03.742307088Z" level=info msg="Loading containers: start."
time="2022-04-16T04:28:03.757473421Z" level=warning msg="Running iptables --wait -t nat -L -n failed with message: `iptables v1.8.7 (legacy): can't initialize iptables table `nat': iptables who? (do you need to insmod?)\nPerhaps iptables or your kernel needs to be upgraded.`, error: exit status 3"
time="2022-04-16T04:28:03.973541463Z" level=info msg="stopping event stream following graceful shutdown" error="<nil>" module=libcontainerd namespace=moby
time="2022-04-16T04:28:03.974672671Z" level=info msg="stopping healthcheck following graceful shutdown" module=libcontainerd
time="2022-04-16T04:28:03.975118338Z" level=info msg="stopping event stream following graceful shutdown" error="context canceled" module=libcontainerd namespace=plugins.moby
failed to start daemon: Error initializing network controller: 
error obtaining controller instance: failed to create NAT chain DOCKER: 
iptables failed: iptables -t nat -N DOCKER: iptables v1.8.7 (legacy):
can't initialize iptables table `nat': iptables who?
(do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
 (exit status 3)

Docker版本的输出

Server: Docker Desktop 4.7.0 (77141)
 Engine:
  Version:          20.10.14
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.15
  Git commit:       87a90dc
  Built:            Thu Mar 24 01:45:44 2022
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.5.11
  GitCommit:        3df54a852345ae127d1fa3092b95168e4a88e2f8
 runc:
  Version:          1.0.3
  GitCommit:        v1.0.3-0-gf46b6ba
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

I am trying to run an amd64 docker-in-docker (dind) container on an arm64 host (Apple silicon), because some images to be run on this dind are amd64 only (e.g. MySQL-5.7).

Run this command on a Mac with Apple chip:

docker run --platform linux/amd64 --privileged --name dind docker:dind

The error message got:

......
time="2022-04-16T04:28:03.742307088Z" level=info msg="Loading containers: start."
time="2022-04-16T04:28:03.757473421Z" level=warning msg="Running iptables --wait -t nat -L -n failed with message: `iptables v1.8.7 (legacy): can't initialize iptables table `nat': iptables who? (do you need to insmod?)\nPerhaps iptables or your kernel needs to be upgraded.`, error: exit status 3"
time="2022-04-16T04:28:03.973541463Z" level=info msg="stopping event stream following graceful shutdown" error="<nil>" module=libcontainerd namespace=moby
time="2022-04-16T04:28:03.974672671Z" level=info msg="stopping healthcheck following graceful shutdown" module=libcontainerd
time="2022-04-16T04:28:03.975118338Z" level=info msg="stopping event stream following graceful shutdown" error="context canceled" module=libcontainerd namespace=plugins.moby
failed to start daemon: Error initializing network controller: 
error obtaining controller instance: failed to create NAT chain DOCKER: 
iptables failed: iptables -t nat -N DOCKER: iptables v1.8.7 (legacy):
can't initialize iptables table `nat': iptables who?
(do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
 (exit status 3)

Output of docker version

Server: Docker Desktop 4.7.0 (77141)
 Engine:
  Version:          20.10.14
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.15
  Git commit:       87a90dc
  Built:            Thu Mar 24 01:45:44 2022
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.5.11
  GitCommit:        3df54a852345ae127d1fa3092b95168e4a88e2f8
 runc:
  Version:          1.0.3
  GitCommit:        v1.0.3-0-gf46b6ba
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

御守 2025-01-28 18:16:57

在Github问了同样的问题,并得到了答案
https://github.com/docker.com/docker/docker/for-mac/issues/6284

基本上没有直接解决方案:

这是不可能的。仿真层不支持IP路由功能。

但是您可以这样做:

在ARM主机上,使用ARM64 dind,

docker run --privileged --name dind docker:dind

然后运行mysql:5.7容器(仅具有linux/amd64架构)代码> - 平台linux/amd64

docker run --platform linux/amd64 --name some-mysql -e MYSQL_ROOT_PASSWORD=foopass -p3306:3306 -d mysql:5.7

等效地,您可以docker pull - platform linux/amd64 mysql:5.7首先,然后docker run note - 平台标志。

Asked the same question in github, and got an answer
https://github.com/docker/for-mac/issues/6284

Basically it has no direct solution:

This is not possible. The emulation layer does not support ip routing capabilities.

But you can do this:

on an ARM host, bring up a arm64 dind with

docker run --privileged --name dind docker:dind

And then run an mysql:5.7 container (which only has linux/amd64 architecture) with --platform linux/amd64

docker run --platform linux/amd64 --name some-mysql -e MYSQL_ROOT_PASSWORD=foopass -p3306:3306 -d mysql:5.7

Equivalently, you can docker pull --platform linux/amd64 mysql:5.7 at first, and then docker run without the --platform flag.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文