iptables: No chain/target/match by that name.

iptables: No chain/target/match by that name.

重启redis镜像的时候报错如下:

ERROR: for redis Cannot start service redis: driver failed programming external connectivity on endpoint redis (f5211771e5a0ee705edb72f8a8dfbca2503456ab0e8330a32932b029a7c0568d): (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 6379 -j DNAT --to-destination 192.168.80.2:6379 ! -i br-fbefac0273aa: iptables: No chain/target/match by that name.

原因:

docker 服务启动的时候,docker服务会向iptables注册一个链,以便让docker服务管理的containner所暴露的端口之间进行通信。通过命令iptables -L可以查看iptables 链。如果你删除了iptables中的docker链,或者iptables的规则被丢失了(例如重启firewalld,我就是使用了systemctl stop iptables导致链丢失),docker就会报这个错误。

解决办法:

systemctl restart docker 重启docker服务,之后,正确的iptables规则就会被创建出来。

参考:

Docker 启动时报错:iptables:No chain/target/match by the name

版权

评论