情况一:
dockcer info 查看服务情况
发现如下预警信息:
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
查看 /etc/sysctl.conf配置是否包含:
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-arptables = 1
net.ipv4.ip_forward = 1
没有需要添加,添加完执行
sysctl -p
如果报错:
cannot stat /proc/sys/net/bridge/bridge-nf-call-iptables
cannot stat /proc/sys/net/bridge/bridge-nf-call-ip6tables
需要加载模块:
modprobe br_netfilter
再次执行sysctl -p
到这里如果还不能解决问题
查看iptables -L是否包含docker的相关规则
如果没有执行下面指令:
#filter表规则
iptables -N DOCKER
iptables -N DOCKER-ISOLATION-STAGE-1
iptables -N DOCKER-ISOLATION-STAGE-2
iptables -N DOCKER-USER
iptables -A FORWARD -j DOCKER-USER
iptables -A FORWARD -j DOCKER-ISOLATION-STAGE-1
iptables -A FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -o docker0 -j DOCKER
iptables -A FORWARD -i docker0 ! -o docker0 -j ACCEPT
iptables -A FORWARD -i docker0 -o docker0 -j ACCEPT
iptables -A DOCKER-ISOLATION-STAGE-1 -i docker0 ! -o docker0 -j DOCKER-ISOLATION-STAGE-2
iptables -A DOCKER-ISOLATION-STAGE-1 -j RETURN
iptables -A DOCKER-ISOLATION-STAGE-2 -o docker0 -j DROP
iptables -A DOCKER-ISOLATION-STAGE-2 -j RETURN
iptables -A DOCKER-USER -j RETURN
#nat表规则
iptables -t nat -N DOCKER
iptables -t nat -A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER
iptables -t nat -A OUTPUT ! -d 127.0.0.0/8 -m addrtype --dst-type LOCAL -j DOCKER
iptables -t nat -A POSTROUTING -s 172.17.0.0/16 ! -o docker0 -j MASQUERADE
iptables -t nat -A DOCKER -i docker0 -j RETURN
最后重启docker
情况二
centos7 docker无法外网访问问题解决办法:
停止docker
systemctl stop docker
安装bridge-utils
yum install -y bridge-utils
关闭docker0网桥
ip link set dev docker0 down
删除docker0网桥
brctl delbr docker0
添加docker0网桥
brctl addbr docker0
添加网桥信息
ip addr add 172.17.0.1/24 dev docker0
启动docker0网桥
ip link set dev docker0 up
查看网桥是否正常
ip addr
启动docker
systemctl restart docker
© 版权声明
文章版权归作者所有,未经允许请勿转载。
相关文章
暂无评论...