gpt4 book ai didi

centos - Docker:ping:未知主机 yahoo.com

转载 作者:太空宇宙 更新时间:2023-11-03 17:14:59 24 4
gpt4 key购买 nike

以下是我尝试过的所有方法:

使用 -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

感谢任何建议。

最佳答案

听起来 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

关于centos - Docker:ping:未知主机 yahoo.com,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20197476/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com