我在Ubuntu 13.10 (Saucy Salamander)上安装了Docker,当我在控制台输入:

sudo docker pull busybox

我得到以下错误:

Pulling repository busybox
2014/04/16 09:37:07 Get https://index.docker.io/v1/repositories/busybox/images: dial tcp: lookup index.docker.io on 127.0.1.1:53: no answer from server

码头工人版本:

$ sudo docker version

Client version: 0.10.0
Client API version: 1.10
Go version (client): go1.2.1
Git commit (client): dc9c28f
Server version: 0.10.0
Server API version: 1.10
Git commit (server): dc9c28f
Go version (server): go1.2.1
Last stable version: 0.10.0

我在一个没有身份验证的代理服务器后面,这是我的/etc/apt/apt.conf文件:

Acquire::http::proxy "http://192.168.1.1:3128/";
Acquire::https::proxy "https://192.168.1.1:3128/";
Acquire::ftp::proxy "ftp://192.168.1.1:3128/";
Acquire::socks::proxy "socks://192.168.1.1:3128/";

我做错了什么?


当前回答

在Ubuntu 14.04 (Trusty Tahr)和Docker 1.9.1上,我只是取消了http_proxy行注释,更新了值,然后重新启动Docker服务。

export http_proxy="http://proxy.server.com:80"

然后

service docker restart

其他回答

在Ubuntu 14.04 (Trusty Tahr)和Docker 1.9.1上,我只是取消了http_proxy行注释,更新了值,然后重新启动Docker服务。

export http_proxy="http://proxy.server.com:80"

然后

service docker restart

为了解决Docker构建中的curl问题,我在Dockerfile中添加了以下内容:

ENV http_proxy=http://infoprx2:8080
ENV https_proxy=http://infoprx2:8080
RUN apt-get update && apt-get install -y curl vim

注意,ENV语句在RUN语句之前。

为了使Docker守护进程能够访问Internet(我使用Kitematic和boot2docker),我在/var/lib/boot2docker/profile中添加了以下内容:

export HTTP_PROXY=http://infoprx2:8080
export HTTPS_PROXY=http://infoprx2:8080

然后我用sudo /etc/init.重启Dockerd /码头工人重新启动。

因为我还不能发表评论:

对于CentOS 7,我需要在“docker”中激活EnvironmentFile。使用systemd控制和配置Docker。

编辑:我正在添加由Nilesh提出的解决方案。我需要打开“/etc/systemd/system/docker”。服务”,我必须在部分中添加

(服务) EnvironmentFile = - / etc / sysconfig /码头工人

直到这时,文件“etc/sysconfig/docker”才被加载到我的系统上。

在CentOS上,Docker的配置文件在:

/etc/sysconfig/docker

添加下面的代码行帮助我让Docker守护进程在代理服务器后工作:

HTTP_PROXY="http://<proxy_host>:<proxy_port>"
HTTPS_PROXY="http://<proxy_host>:<proxy_port>"

在Docker的新版本中,Docker -engine,在一个基于systemd的发行版中,你应该在/lib/systemd/system/ Docker中添加环境变量line。服务,正如其他人所提到的:

Environment="HTTP_PROXY=http://hostname_or_ip:port/"