启动容器时报错

报错内容:

iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 3306 -j DNAT --to-destination 192.168.xx.xx:80 ! -i docker0 
iptables: No chain/target/match by that name. (exit status 1)).

重启docker时报错

systemctl restart docker
Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xeu docker.service" for details.

重启docker报错

journalctl -u docker.service -n 100 --no-pager

查看日志

failed to find iptables: exec: "iptables": executable file not found in $PATH
failed to start daemon: Error initializing network controller: error obtaining controller instance: failed to register "bridge" driver: failed to create NAT chain DOCKER: iptables not found

发现是系统缺少 iptables命令,安装iptables

# 更新包列表
sudo apt-get update

# 安装 iptables
sudo apt-get install -y iptables

安装后仍然找不到 iptables

查找 iptables 位置

sudo find /usr -name “iptables” -type f
sudo find /sbin -name “iptables” -type f
dpkg -L iptables | grep bin

创建符号链接

sudo ln -sf /usr/sbin/iptables-nft /usr/sbin/iptables
sudo ln -sf /usr/sbin/ip6tables-nft /usr/sbin/ip6tables
``

验证是否安装成功

iptables --version

测试重启容器成功

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐