Proxy 在EC2实例上的代理后面使用docker

Proxy 在EC2实例上的代理后面使用docker,proxy,amazon-ec2,docker,Proxy,Amazon Ec2,Docker,我正在尝试在EC2虚拟机实例中运行docker。该实例位于http代理之后。 据我所知,docker的安装进展顺利 下面是实例信息 Linux ip-X-X-X-X 3.8.0-31-generic #46~precise1-Ubuntu SMP Wed Sep 11 18:21:16 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux 我看到的docker版本是 Docker version 0.6.3, build b0a49a3 当我尝试运行一个简单的doc

我正在尝试在EC2虚拟机实例中运行docker。该实例位于http代理之后。 据我所知,docker的安装进展顺利

下面是实例信息

Linux ip-X-X-X-X 3.8.0-31-generic #46~precise1-Ubuntu SMP Wed Sep 11 18:21:16 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
我看到的docker版本是

Docker version 0.6.3, build b0a49a3
当我尝试运行一个简单的docker命令时,它会挂起很长时间

$sudo docker run -i -t ubuntu /bin/bash
Unable to find image 'ubuntu' (tag: latest) locally
Pulling repository ubuntu
我觉得这与我的HTTP代理设置有关

我试着用不同的方式设置代理

例如,基于我尝试过,但仍然不起作用

$sudo HTTP_PROXY=http://proxy.xyz.com:8080 docker run -i -t ubuntu /bin/bash
Unable to find image 'ubuntu' (tag: latest) locally
Pulling repository ubuntu

你知道我在这里遗漏了什么吗

您需要使用HTTP_代理环境变量运行Docker守护程序,因为图像的提取是通过守护程序进行的。如果你在Ubuntu上,这可以通过修改
/etc/init/docker.conf
来实现

更新:


我们现在也正确地支持
/etc/default/docker
,所以现在(在Ubuntu和Debian上)实现这一点的最好方法是通过
导出http_proxy=…
内部
/etc/default/docker

您需要使用http_proxy环境变量运行docker守护程序,因为图像的提取是通过守护进程进行的。如果你在Ubuntu上,这可以通过修改
/etc/init/docker.conf
来实现

更新:


我们现在也正确地支持
/etc/default/docker
,所以现在(在Ubuntu和Debian上)实现这一点的最好方法是通过
导出http_proxy=…
内部
/etc/default/docker

在修改配置文件后,请不要忘记重新启动docker守护程序:

sudo service docker restart

要应用代理。

在修改配置文件后,要添加到tianon的答案中,请不要忘记重新启动docker守护程序:

sudo service docker restart

要在Amazon Linux上应用代理。

,请在
/etc/sysconfig/docker

export no_proxy='localhost,127.0.0.0/8'
export NO_PROXY='localhost,127.0.0.0/8'
export http_proxy=http://<YOUR_PROXY>:<PROXY_PORT>/
export HTTPS_PROXY=http://<YOUR_PROXY>:<PROXY_PORT>/
export https_proxy=http://<YOUR_PROXY>:<PROXY_PORT>/
export HTTP_PROXY=http://<YOUR_PROXY>:<PROXY_PORT>/
export no_proxy='localhost,127.0.0.0/8'
export NO_PROXY='localhost,127.0.0.0/8'
导出http_proxy=http://:/
导出HTTPS_PROXY=http://:/
导出https_proxy=http://:/
导出HTTP_PROXY=HTTP://:/
然后重新启动docker守护进程
服务docker restart

在Amazon Linux上,在
/etc/sysconfig/docker

export no_proxy='localhost,127.0.0.0/8'
export NO_PROXY='localhost,127.0.0.0/8'
export http_proxy=http://<YOUR_PROXY>:<PROXY_PORT>/
export HTTPS_PROXY=http://<YOUR_PROXY>:<PROXY_PORT>/
export https_proxy=http://<YOUR_PROXY>:<PROXY_PORT>/
export HTTP_PROXY=http://<YOUR_PROXY>:<PROXY_PORT>/
export no_proxy='localhost,127.0.0.0/8'
export NO_PROXY='localhost,127.0.0.0/8'
导出http_proxy=http://:/
导出HTTPS_PROXY=http://:/
导出https_proxy=http://:/
导出HTTP_PROXY=HTTP://:/
然后重新启动docker守护进程
服务docker restart

您能分享更多信息吗?如何在docker.conf文件中添加代理设置?我尝试添加https_proxy=/usr/bin/docker-d,但它不起作用。我仍然得到连接超时。你能分享更多信息吗?如何在docker.conf文件中添加代理设置?我尝试添加https_proxy=/usr/bin/docker-d,但它不起作用。我仍然得到连接超时。