docker 报错:

Error response from daemon: Cannot restart container hello: driver failed programming external connectivity on endpoint hello (e58d18c830689e296c0fafdd98bf56e973cee3a3fbee8a3f002d46784f69ae70): (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 6081 -j DNAT --to-destination 172.0.0.2:8080 ! -i docker0: iptables: No chain/target/match by that name.
(exit status 1))

翻译:无法重新启动容器hello:驱动程序未能在端点hello上编程外部连接:(iptables失败:iptables–wait–t nat–A DOCKER–p tcp–d 0/0–dport 6081–j DNAT–to destination 172.18.0.2:8080!-i docker0:iptables:没有该名称的链/目标/匹配。

错误原因:

docker 服务启动的时候,docker服务会向iptables注册一个链,以便让docker服务管理的containner所暴露的端口之间进行通信。

如果你删除了iptables中的docker链,或者iptables的规则被丢失了(例如重启firewalld),原有的docker端口映射不存在了。
可以通过命令iptables -L可以查看iptables链,如果是空的或者上面报错的映射端口不存在,那你的问题应该是这个原因了。

解决方法:

命令:

sudo systemctl restart docker

然后将每个容器重启即可,无需删除容器,无需重装docker。

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐