我正在尝试在Arch Linux上运行docker。我的容器无法连接到互联网,因此无法添加软件等。我按照说明设置了转发:
sudo sysctl net.ipv4.ip_forward=1
但我仍然会遇到这样的错误:
bpotter@lore➜ ~/tmp» docker run ubuntu apt-get install -y ping
Reading package lists...
Building dependency tree...
The following NEW packages will be installed:
iputils-ping
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 56.1 kB of archives.
After this operation, 143 kB of additional disk space will be used.
Err http://archive.ubuntu.com/ubuntu/ precise/main iputils-ping amd64 3:20101006-1ubuntu1
Temporary failure resolving 'archive.ubuntu.com'
Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/i/iputils/iputils-ping_20101006-1ubuntu1_amd64.deb Temporary failure resolving 'archive.ubuntu.com'
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
和此:
bpotter@lore➜ ~/tmp» docker run abhay/ping_function 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 2007ms
我正在考虑建立一个桥接设备,但我认为允许转发应该使这不必要。如果我不需要,我宁愿不开始使用netctl。
如何配置我的机器和泊坞窗,以便从Docker容器中连接到互联网?
答案 0 :(得分:1)
我在以前的工作场所看到同样的问题。我不知道在这种情况下原因是否相同(或者甚至是否仍然存在问题),但是我的公司网络阻止了默认的docker dns服务器(来自容器内部 - 8.8.8.8)
解决方法是在运行容器时使用--dns标志。