启动 docker 容器报错 (iptables failed: iptables --wait -t filter -A DOCKER ! -i docker0 -o docker0

前言

  • centos7
  • phpstudy 1.2 linux 版

启动 docker 容器报错

shell> docker start nexus3
Error response from daemon: driver failed programming external connectivity on endpoint nexus3 (a37100872332dd85e4ab6688b97bea3c4fb420c7d4740225a69d1cec700fe757):  (iptables failed: iptables --wait -t filter -A DOCKER ! -i docker0 -o docker0 -p tcp -d 172.17.0.3 --dport 8081 -j ACCEPT: iptables: No chain/target/match by that name.(exit status 1))
Error: failed to start containers: nexus3

报错原因

网上查,是网络原因。

结合自身来看,我在 phpstudy 开启了服务器防火墙后,安装的docker。今天在 phpstudy 中禁用了服务器防火墙。禁用服务器防火墙后,才发生的此问题。
phpstudy 带的服务器防火墙是iptable(centos7带的防火墙是firewalld,不要混了),错误提示的也是iptable问题。这就对上了。

解决办法1:重建docker0网络

重建docker0网络,让docker0网络适应无防火墙的情况。

在宿主机执行下面的命令:

shell>  pkill docker 
shell>  iptables -t nat -F 
shell>  ifconfig docker0 down 
shell>  brctl delbr docker0 
shell>  docker -d 
shell>  systemctl restart docker 重启docker服务

解决办法2:恢复防火墙状态

在 phpstudy 中启用服务器防火墙,什么都不需要动,就好了。

另:如果在未启用防火墙状态下安装的docker,且安装docker后启用防火墙的,也会遇到这个问题。

参考

https://blog.csdn.net/blueyan163/article/details/68928065


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部