我怎样才能将我的docker连接到互联网?

我正在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 

我正在考虑build立一个桥接设备,但是我认为允许转发应该是不必要的。 如果我不需要,我宁愿不开始使用netctl。

我怎样才能configuration我的机器和docker,使我可以连接到我的docker集装箱内的互联网?

我在以前的工作场所看到了同样的问题。 我不知道在这种情况下原因是否相同(甚至是否仍然是问题),但是默认的docker dns服务器(来自容器 – 8.8.8.8)被我的公司networking阻塞。

解决scheme是在运行容器时使用–dns标志。