打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
docker端口映射或启动容器时报错 driver failed programming external connectivity on endpoint quirky

docker端口映射或启动容器时报错  Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen

 

现象:

[root@localhost ~]# docker run -d -p 9000:80 centos:httpd /bin/sh -c /usr/local/bin/start.sh
d5b2bd5a7bc4895a973fe61efd051847047d26385f65c278aaa09e4fa31c4d76
docker: Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen (6bda693d1143657e46bee0300276aa05820da2b21a3d89441e820d1a274c48b6): (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 9000 -j DNAT --to-destination 172.17.0.2:80 ! -i docker0: iptables: No chain/target/match by that name.
(exit status 1)).

[root@localhost ~]# docker start d5b2bd5a7bc4 
Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen (4127da7466709fd45695a1fbe98e13c2ac30c2a554e18fb902ef5a03ba308438): (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 9000 -j DNAT --to-destination 172.17.0.2:80 ! -i docker0: iptables: No chain/target/match by that name.
(exit status 1))
Error: failed to start containers: d5b2bd5a7bc4

 

原因:
docker服务启动时定义的自定义链DOCKER由于 centos7 firewall 被清掉

firewall的底层是使用iptables进行数据过滤,建立在iptables之上,这可能会与 Docker 产生冲突。

当 firewalld 启动或者重启的时候,将会从 iptables 中移除 DOCKER 的规则,从而影响了 Docker 的正常工作。

当你使用的是 Systemd 的时候, firewalld 会在 Docker 之前启动,但是如果你在 Docker 启动之后再启动 或者重启 firewalld ,你就需要重启 Docker 进程了。

重启docker服务及可重新生成自定义链DOCKER

  1. Chain PREROUTING (policy ACCEPT)
  2. target     prot opt source               destination        
  3. DOCKER     all  --  0.0.0.0/0            0.0.0.0/0            ADDRTYPE match dst-type LOCAL
  4. Chain INPUT (policy ACCEPT)
  5. target     prot opt source               destination        
  6. Chain OUTPUT (policy ACCEPT)
  7. target     prot opt source               destination        
  8. DOCKER     all  --  0.0.0.0/0           !127.0.0.0/8          ADDRTYPE match dst-type LOCAL
  9. Chain POSTROUTING (policy ACCEPT)
  10. target     prot opt source               destination        
  11. MASQUERADE  all  --  172.17.0.0/16        0.0.0.0/0          
  12. MASQUERADE  tcp  --  172.17.0.2           172.17.0.2           tcp dpt:8080
  13. Chain DOCKER (2 references)
  14. target     prot opt source               destination        
  15. RETURN     all  --  0.0.0.0/0            0.0.0.0/0          
  16. DNAT       tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:8888 to:172.17.0.2:8080
  17. root@router:playbook#iptables -t nat -nL
  18. Chain PREROUTING (policy ACCEPT)
  19. target     prot opt source               destination        
  20. DOCKER     all  --  0.0.0.0/0            0.0.0.0/0            ADDRTYPE match dst-type LOCAL
  21. Chain INPUT (policy ACCEPT)
  22. target     prot opt source               destination        
  23. Chain OUTPUT (policy ACCEPT)
  24. target     prot opt source               destination        
  25. DOCKER     all  --  0.0.0.0/0           !127.0.0.0/8          ADDRTYPE match dst-type LOCAL
  26. Chain POSTROUTING (policy ACCEPT)
  27. target     prot opt source               destination        
  28. MASQUERADE  all  --  172.17.0.0/16        0.0.0.0/0          
  29. MASQUERADE  tcp  --  172.17.0.2           172.17.0.2           tcp dpt:8080
  30. Chain DOCKER (2 references)
  31. target     prot opt source               destination        
  32. RETURN     all  --  0.0.0.0/0            0.0.0.0/0          
  33. DNAT       tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:8888 to:172.17.0.2:8080



解决:
重启docker服务后再启动容器
systemctl restart docker
docker start foo

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Docker 网络学习笔记
Error response from daemon: driver failed programming external connectivity on endpoint mysql3308 (
ftp服务的搭建和问题解答
linux iptables配置
CentOS iptables配置笔记
防火墙IPTABLES
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服