首页 > 技术文章 > docker 端口映射错误解决方法

coder-duibai 2018-04-12 19:01 原文

今天搞了半天shipyard,在网页上打开时无法显示容器和镜像,最后发现是docker端口映射错误,由于防火墙未关闭:

4月 12 18:51:29 localhost firewalld[757]: 2018-04-12 18:51:29 ERROR: COMMAND_FAILED: '/sbin/iptables -t nat -C POSTROUTING -p tcp -s 172.17.0.7 -d 172.17.0.7 --dport 8080 -j MASQUERADE' faile... by that name.
4月 12 18:51:30 localhost firewalld[757]: 2018-04-12 18:51:30 ERROR: COMMAND_FAILED: '/sbin/iptables -t nat -C DOCKER -p tcp -d 0/0 --dport 8079 -j DNAT --to-destination 172.17.0.7:8080 ! -i ... by that name.
4月 12 18:51:30 localhost firewalld[757]: 2018-04-12 18:51:30 ERROR: COMMAND_FAILED: '/sbin/iptables -t filter -C DOCKER ! -i docker0 -o docker0 -p tcp -d 172.17.0.7 --dport 8080 -j ACCEPT' f... that chain?).
4月 12 18:51:30 localhost firewalld[757]: 2018-04-12 18:51:30 ERROR: COMMAND_FAILED: '/sbin/iptables -t nat -C POSTROUTING -p tcp -s 172.17.0.7 -d 172.17.0.7 --dport 8080 -j MASQUERADE' faile... by that name.
4月 12 18:51:31 localhost firewalld[757]: 2018-04-12 18:51:31 ERROR: COMMAND_FAILED: '/sbin/iptables -t nat -C DOCKER -p tcp -d 0/0 --dport 8079 -j DNAT --to-destination 172.17.0.7:8080 ! -i ... by that name.
4月 12 18:51:31 localhost firewalld[757]: 2018-04-12 18:51:31 ERROR: COMMAND_FAILED: '/sbin/iptables -t filter -C DOCKER ! -i docker0 -o docker0 -p tcp -d 172.17.0.7 --dport 8080 -j ACCEPT' f... that chain?).
4月 12 18:51:31 localhost firewalld[757]: 2018-04-12 18:51:31 ERROR: COMMAND_FAILED: '/sbin/iptables -t nat -C POSTROUTING -p tcp -s 172.17.0.7 -d 172.17.0.7 --dport 8080 -j MASQUERADE' faile... by that name.
4月 12 18:51:32 localhost firewalld[757]: 2018-04-12 18:51:32 ERROR: COMMAND_FAILED: '/sbin/iptables -t nat -C DOCKER -p tcp -d 0/0 --dport 8079 -j DNAT --to-destination 172.17.0.7:8080 ! -i ... by that name.
4月 12 18:51:32 localhost firewalld[757]: 2018-04-12 18:51:32 ERROR: COMMAND_FAILED: '/sbin/iptables -t filter -C DOCKER ! -i docker0 -o docker0 -p tcp -d 172.17.0.7 --dport 8080 -j ACCEPT' f... that chain?).
4月 12 18:51:32 localhost firewalld[757]: 2018-04-12 18:51:32 ERROR: COMMAND_FAILED: '/sbin/iptables -t nat -C POSTROUTING -p tcp -s 172.17.0.7 -d 172.17.0.7 --dport 8080 -j MASQUERADE' faile... by that name.

解决方法:关闭防火墙即可

systemctl stop firewalld

推荐阅读