在EC2实例的代理之后使用docker
我试图在EC2虚拟机实例中运行docker。 该实例位于http代理的后面。 据我可以告诉docker安装好了。
这里是实例信息
Linux ip-XXXX 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_PROXY环境variables来运行Docker守护进程,因为通过守护进程拉取图像。 如果你在Ubuntu上,可以通过修改/etc/init/docker.conf
来完成。
更新:
现在我们也正确地支持/etc/default/docker
,所以现在(Ubuntu和Debian上)最好的方法是通过export http_proxy=...
在/etc/default/docker
。
在Amazon Linux上,在/etc/sysconfig/docker
追加代理variables
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>/
然后重新启动docker守护进程service docker restart
添加到天安答案的东西是在修改configuration文件后不要忘记重新启动docker守护进程:
sudo service docker restart
申请代理。