Docker apt-get更新失败 [英] Docker apt-get update fails

查看:688
本文介绍了Docker apt-get更新失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮我帮忙在我的码头集装箱里工作吗?每当我尝试在docker容器中运行任何apt-get命令时,命令都将失败。我正在运行Docker 1.1.1版,在ubuntu 12.04上构建bd609d2。



当我执行

  $ sudo docker run -i -t ubuntu:14.04 / bin / bash 
#apt-get update

我收到错误说


无法解析'archive.ubuntu.com'


我尝试取消注释/ etc / default / docker


DOCKER_OPTS = - dns 8.8.8.8 --dns 8.8.4.4


但我还是不能ping google.com


ping:unknown host


我确认容器正在使用dns服务器8.8.8.8和8.8.4.4


root @ 0baa87fc6322:/#cat / etc / resolv.conf



nameserver 8.8.8.8



nameserver 8.8.4.4


我可以ping两台服务器,所以我很漂亮e。防火墙不仅仅是放弃了我的数据包。



任何帮助将不胜感激!



谢谢!

解决方案

感谢您的帮助!我发现这是一个dns问题,这是因为一个防火墙。搜索更多之后,我发现这个问题,我在搜索'docker apt-get fail'时找不到





他的问题与我的问题类似,解决方案帮助我解决问题。
我将来为任何找到这个问题的人解决了他的解决方案。


这些Google服务器无法访问从我们的防火墙后面,这就是为什么我们无法解析任何URL。



修复是告诉Docker要使用哪个DNS服务器。这个修复取决于你如何安装Docker:
Ubuntu Package



如果您安装了Ubuntu软件包,请编辑/ etc / default / docker并添加以下行:



DOCKER_OPTS = - dns< your_dns_server_1> --dns< your_dns_server_2>



可以添加与此配置一样多的DNS服务器。编辑此文件后,您将需要重新启动Docker服务:



sudo service docker restart



Binaries



如果您已经通过二进制文件方法(即没有包)安装Docker,那么您在启动Docker守护程序时设置DNS服务器:



sudo docker -d -D --dns --dns&



Can somebody help me get apt-get working in my docker container? Whenever I try running any apt-get command in my docker container, the command fails. I'm running Docker version 1.1.1, build bd609d2 on ubuntu 12.04.

When I do

$ sudo docker run -i -t ubuntu:14.04 /bin/bash
# apt-get update

I get errors saying

Could not resolve 'archive.ubuntu.com'

I tried uncommenting the line below in /etc/default/docker

DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"

but I still can't ping google.com

ping: unknown host

I confirmed that the container is using the dns servers 8.8.8.8 and 8.8.4.4

root@0baa87fc6322:/# cat /etc/resolv.conf

nameserver 8.8.8.8

nameserver 8.8.4.4

and I'm able to ping both servers so I'm pretty sure that a firewall isn't just dropping my packets.

Any help with this would be appreciated!

Thanks!

解决方案

Thanks for all your help! I found out it was a dns problem and that it was because of a firewall. After searching some more I found this question that I wasn't able to find while searching 'docker apt-get fail'

Docker - Network calls fail during image build on corporate network

His problem was similar to mine and the solution helped me get it working. I've copied over his solution for anybody that finds this question in the future.

Those Google servers weren't accessible from behind our firewall, which is why we couldn't resolve any URLs.

The fix is to tell Docker which DNS servers to use. This fix depends on how you installed Docker: Ubuntu Package

If you have the Ubuntu package installed, edit /etc/default/docker and add the following line:

DOCKER_OPTS="--dns <your_dns_server_1> --dns <your_dns_server_2>"

You can add as many DNS servers as you want to this config. Once you've edited this file you'll want to restart your Docker service:

sudo service docker restart

Binaries

If you've installed Docker via the binaries method (i.e. no package), then you set the DNS servers when you start the Docker daemon:

sudo docker -d -D --dns --dns &

这篇关于Docker apt-get更新失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆