简体   繁体   English

Docker:ping:未知主机yahoo.com

[英]Docker: ping: unknown host yahoo.com

Here are all the things I tried: 以下是我尝试过的所有事情:

Ran docker deamon with -dns: 与-dns一起使用docker deamon:

sudo docker -d -dns 8.8.8.8

Made sure that IP forwarding is enabled: 确保启用了IP转发:

$ sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 1

Nameservers are in place: 名称服务器到位:

$ 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

Appreciate any suggestions. 感谢任何建议。

It sounds like Docker's automatic iptables configuration is not working. 这听起来像Docker的自动iptables配置不起作用。 This can often occur if you've changed the host IP address without restarting the Docker daemon. 如果您在不重新启动Docker守护程序的情况下更改了主机IP地址,则通常会发生这种情况。 I would try the following: 我会尝试以下方法:

  1. Ensure you can ping from the host (just to be sure!) 确保您可以从主机ping(只是为了确保!)
  2. Restart the Docker daemon and try again (this should reset iptables configuration) 重启Docker守护进程并重试(这应该重置iptables配置)
  3. Inspect the output from iptables --list --table nat 检查iptables --list --table nat的输出

Mine looks as so: 我看起来如此:

# 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     

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM