当前位置:   article > 正文

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

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
  • 1
  • 2
  • 3
  • 4

报错原因

网上查,是网络原因。

结合自身来看,我在 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服务
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

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

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

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

参考

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/229386
推荐阅读
相关标签
  

闽ICP备14008679号