問題:
Error response from daemon: driver failed programming external connectivity
on endpoint jenkins (a8ea15bf9b3dbed599d059d638f79f9dd5e875556c39bfb41e6563d3feedb81b):
(iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 50000 -j DNAT
--to-destination 172.18.0.6:50000 ! -i br-031aa3930383: iptables: No chain/target/match
by that name.
光看這個報錯: iptables: No chain/target/match by that name,就能夠看出是跟iptables有關
原因(猜測):
如果再啟動docker service的時候網關是關閉的,那么docker管理網絡的時候就不會操作網管的配置(chain docker),然后網關重新啟動了,導致docker network無法對新container進行網絡配置,也就是沒有網管的操作權限,做重啟處理
處理:
service docker restart
或
systemctl restart docker
使用的centos7服務器,在部署docker的過程中,因端口問題有啟停firewalld服務,在centos7里使用firewalld代替了iptables。在啟動firewalld之后,iptables還會被使用,屬於引用的關系。所以在docker run的時候,iptables list里沒有docker chain,重啟docker engine服務后會被加入到iptables list里面。(有必要深入研究一下docker network)
另一個方法:
關閉網關(不建議)
systemctl stop firewalld
systemctl stop iptables