无法在 qemu 下初始化 iptables 表“nat”

无法在 qemu 下初始化 iptables 表“nat”

我在 s390x 容器内启动 docker 时遇到问题在 qemu 下在 amd64 上运行的 Ubuntu 18.04 主机上。

遵循的步骤(在 amd64 主机上):

docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker run --privileged -it s390x/ubuntu:18.04
apt-get update
curl -fsSL https://download.docker.com/linux/ubuntu/gpg
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository "deb [arch=s390x] https://download.docker.com/linux/ubuntu bionic stable"
apt-cache policy docker-ce
service  docker start

Docker 服务未启动。/var/log/docker.log 显示

time="2021-04-01T17:57:26.643424257Z" level=warning msg="Running modprobe nf_nat failed with message:  error: exec: \"modprobe\": executable file not found in $PATH"
time="2021-04-01T17:57:26.643706873Z" level=warning msg="Running modprobe xt_conntrack failed with message: error: exec: \"modprobe\": executable file not found in $PATH"
Error starting daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain DOCKER: iptables failed: iptables -t nat -N DOCKER: iptables v1.6.1: can't initialize iptables table `nat': iptables who? (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded

是否需要更改任何设置/需要添加步骤?

答案1

错误信息:

iptables v1.6.1: can't initialize iptables table `nat': iptables who? (do you need to insmod?)

指出nat找不到该表。

这意味着您的操作系统缺少对 NAT 的支持。您可以通过运行 来加载 NAT 模块modprobe nf_nat_ipv4

答案2

看起来跨架构中的 docker 尚不受支持。如果我们使用 -v /var/run/docker.sock:/var/run/docker.sock ,docker 将始终作为 s390x 容器中的客户端和 amd64 中的服务器运行。

相关内容