Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将docker连接到internet?_Docker - Fatal编程技术网

如何将docker连接到internet?

如何将docker连接到internet?,docker,Docker,我正在尝试在ArchLinux上运行docker。我的容器无法连接到internet,因此无法添加软件等。我已按照指示设置转发: 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

我正在尝试在ArchLinux上运行docker。我的容器无法连接到internet,因此无法添加软件等。我已按照指示设置转发:

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,以便从docker容器中连接到internet?

我在以前的工作场所也遇到了同样的问题。我不知道这起事件的原因是否相同(甚至不知道这是否仍然是一个问题),但默认的docker dns服务器(来自容器内-8.8.8.8)被我的公司网络阻止


解决方案是在运行容器时使用--dns标志。

一年后您是否仍遇到此问题?通常情况下,容器应该可以通过桥接docker0访问互联网。我不再有这个问题。这可能是由docker或arch Linux更新解决的。