我在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/";

我做错了什么?


当前回答

也许你需要设置小写变量。在我的例子中,我的/etc/systemd/system/docker.service.d/http-proxy.conf文件看起来像这样:

[Service]
Environment="ftp_proxy=http://<user>:<password>@<proxy_ip>:<proxy_port>/"
Environment="http_proxy=http://<user>:<password>@<proxy_ip>:<proxy_port>/"
Environment="https_proxy=http://<user>:<password>@<proxy_ip>:<proxy_port>/"

好运!:)

其他回答

如果你正在使用新的Mac Docker(或Windows Docker),只需右键单击Docker托盘图标,选择首选项(Windows:设置),然后进入高级,在代理下面指定代理设置。单击“应用并重新启动”,等待Docker重新启动。

在防火墙后面,我也面临着同样的问题。请遵循以下步骤:

$ sudo vim /etc/systemd/system/docker.service.d/http_proxy.conf
[Service]
Environment="HTTP_PROXY=http://username:password@IP:port/"

不要使用或删除https_prxo .conf文件。

重新加载并重新启动Docker容器:

$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
$ docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:2557*********************************8
Status: Downloaded newer image for hello-world:latest

在Ubuntu上,你需要为Docker守护进程设置http_proxy,而不是客户端进程。这是在/etc/default/docker中完成的(参见这里)。

在RHEL6.6上只能这样(注意使用export):

/etc/sysconfig/docker

export http_proxy="http://myproxy.example.com:8080"
export https_proxy="http://myproxy.example.com:8080"

注意:两者都可以使用http协议。)

感谢https://crondev.com/running-docker-behind-proxy/

因为我还不能发表评论:

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

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

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

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