解决 Docker 启动时报错:iptables: No chain/target/match by the name
问题背景
在服务器上修改了端口的相关配置,导致jenkins
的容器启动失败,报如下错误:
Cannot start service jenkins: driver failed programming external connectivity on endpoint jenkins (289b01f799f57f40a1bca130235548bf664dcb7ca042ea74f6fa7fa578c5913c): (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 50000 -j DNAT --to-destination 172.17.0.2:50000 ! -i docker0: iptables: No chain/target/match by that name.
解决方案
根据前半段的信息去 google 上查找问题,发现并没有相关的资料。看到里面有关键字iptables
,觉得问题应该在这。直接搜索iptables: No chain/target/match by that name
找到了答案。
1. 清空所有的 iptables chains
sudo iptables -t filter -F
sudo iptables -t filter -X
2. 重启 docker 服务即可
sudo systemctl restart docker
参考资料:
Running docker container : iptables: No chain/target/match by that name