docker0: iptables: No chain/target/match by that name錯誤處理

今天運行這個命令時報錯docker

docker run -it --name Haproxy --link app1:app1 --link app2:app2 -p 6302:6301 -v ~/Projects/HAProxy:/tmp haproxy /bin/bash bash

報錯信息:app

docker: Error response from daemon: failed to create endpoint Haproxy on network bridge: iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 6302 -j DNAT --to-destination 192.168.0.8:6301 ! -i docker0: iptables: No chain/target/match by that name.tcp

看着信息提示,能夠大概知道iptables配置的問題,且跟docker有關。
ide

查看iptables配置文件spa

cat /etc/sysconfig/iptables (主要是filter和nat的配置)rest

*filterorm

:INPUT DROP [0:0]ip

:FORWARD ACCEPT [0:0]get

:OUTPUT ACCEPT [17:2536]

:syn-flood - [0:0]

-A INPUT -i lo -j ACCEPT

*nat

:PREROUTING ACCEPT [0:0]

:INPUT ACCEPT [0:0]

:OUTPUT ACCEPT [0:0]

:POSTROUTING ACCEPT [0:0]

:OUTPUT_direct - [0:0]

:POSTROUTING_ZONES - [0:0]

:POSTROUTING_ZONES_SOURCE - [0:0]

這裏看到filter和nat並無docker的配置信息,因此添加上對應的信息以下:

*filter

:INPUT DROP [0:0]

:FORWARD ACCEPT [0:0]

:OUTPUT ACCEPT [17:2536]

:syn-flood - [0:0]

:DOCKER - [0:0]

*nat

:PREROUTING ACCEPT [0:0]

:INPUT ACCEPT [0:0]

:OUTPUT ACCEPT [0:0]

:DOCKER - [0:0]


重啓iptables

sudo systemctl restart iptables.service 

從新啓動容器便可

相關文章
相關標籤/搜索