【问题标题】:Docker: ping: unknown host yahoo.comDocker:ping:未知主机 yahoo.com
【发布时间】:2013-12-10 10:32:15
【问题描述】:

这是我尝试过的所有事情:

使用 -dns 运行 docker 守护进程:

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

感谢任何建议。

【问题讨论】:

    标签: centos docker


    【解决方案1】:

    听起来 Docker 的自动 iptables 配置不起作用。如果您在未重新启动 Docker 守护程序的情况下更改了主机 IP 地址,则通常会发生这种情况。我会尝试以下方法:

    1. 确保您可以从主机 ping 通(只是为了确定!)
    2. 重启 Docker 守护进程并重试(这应该重置 iptables 配置)
    3. 检查来自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     
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-10
      • 2021-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多