docker 启动容器报错:
docker: Error response from daemon: driver failed programming external connectivity on endpoint beautiful_lalande (c3779ef966ffc7a33d2c157896a0c5e017478ecb6677b88ab4cb7f31a2e43bb2): (iptables failed:
iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 9999 -j DNAT --to-destination 172.17.0.2:80 ! -i docker0: iptables: No chain/target/match by that name.
1.进入这个目录
cd /lib/systemd/system
vim docker.service
# 添加如下:
ExecStartPost=/sbin/iptables -P FORWARD ACCEPT
[Unit] 2 Description=Docker Application Container Engine 3 Documentation=https://docs.docker.com 4 After=network-online.target docker.socket firewalld.service containerd.service 5 Wants=network-online.target 6 Requires=docker.socket containerd.service 7 8 [Service] 9 Type=notify 10 # the default is not to use systemd for cgroups because the delegate issues still 11 # exists and systemd currently does not support the cgroup feature set required 12 # for containers run by docker 13 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock 14 ExecStartPost=/sbin/iptables -P FORWARD ACCEPT 15 ExecReload=/bin/kill -s HUP $MAINPID 16 TimeoutSec=0 17 RestartSec=2 18 Restart=always
2.重启
[root@localhost system]# systemctl daemon-reload
[root@localhost system]# systemctl restart docker