栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

docker出现Error response from daemon: driver failed programming external connectivity on endpoint解决方法

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

docker出现Error response from daemon: driver failed programming external connectivity on endpoint解决方法

目录
  • 1. 问题所示
  • 2. 分析原理
  • 3. 问题解决

1. 问题所示

出现了如下问题

即简单测试run命令
运行一个简易命令不加端口的tomcat:docker run -d -P --name tomcat01 tomcat

docker: Error response from daemon: driver failed programming external connectivity on endpoint tomcat01 (00028237b8dd7b21dbce757be3bf2df0e0fcfa6c3987cac68c42d2fb6603b42d): 
(iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 49162 -j DNAT --to-destination 172.17.0.2:8080 ! -i docker0: iptables: No chain/target/match by that name.
(exit status 1)).

2. 分析原理

在网上查了很多资料,主要是因为在启动docker容器的时候或者做docker配置的时候,还对防火墙设置重新启动等配置
这样会清除docker的相关配置,导致在查询防火墙规则的时候显示不到docker的链
iptables -L 查询iptables 链

而docker容器的底层原理:
在启动docker的时候会自动在iptables中注册一个链,通过防火墙的链也可以找到其注册的信息,主要注册这些链,是docker中的容器为了暴露端口而使用的

具体原因是你删除了iptables中的链
删除链接的方式有很多种

  • 重启firewalld防火墙即可对其清除,firewalld是centos7以上,iptables是centos6以下都会有,而firewalld的底层是涉及在iptables上的,在启动firewalld的时候会自动删除iptables链的相关链接
  • 删除该链接的其他方式博主暂未遇到有特殊情况的,待发现

所以在涉及防火墙firewalld的命令或者是iptables中的命令的时候
小心删除其涉及docker的链
具体这两个命令可查看其博主相关的文章
linux之防火墙命令firewall、iptable以及端口号等详解诠释(全)

3. 问题解决

既然是firewalld重启导致
而docker重启又会将其注册iptables链回来
那么 我们只需要将其重启docker容器即可解决该问题

systemctl restart docker

再次查询器docker的链iptables -L
或者是通过这条命令查询iptables -t nat -nL

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/860807.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号