以下是我尝试过的所有事情:
使用-dns来使用docker deamon:
sudo docker -d -dns 8.8.8.8
确保已启用IP转发:
$ sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 1
名称服务器到位:
$ docker -dns '8.8.8.8' run centos:6.4 ping -c 3 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
--- 8.8.8.8 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 12000ms
感谢任何建议。
答案 0 :(得分:0)
听起来Docker的自动iptables配置无效。如果您在不重新启动Docker守护程序的情况下更改了主机IP地址,则通常会发生这种情况。我会尝试以下方法:
iptables --list --table nat
我看起来如此:
# iptables --list --table nat
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
DOCKER all -- anywhere anywhere ADDRTYPE match dst-type LOCAL
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
DOCKER all -- anywhere !127.0.0.0/8 ADDRTYPE match dst-type LOCAL
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
MASQUERADE all -- <redacted>/24 !<redacted>/24
MASQUERADE all -- <redacted>/16 !<redacted>/16
Chain DOCKER (2 references)
target prot opt source destination