【问题标题】:Using docker behind a proxy on an EC2 instance在 EC2 实例上的代理后面使用 docker
【发布时间】:2013-10-13 04:24:39
【问题描述】:

我正在尝试在 EC2 VM 实例中运行 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 代理设置有关。

我尝试以不同的方式设置代理。

例如基于this我试过了,但还是不行。

$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

知道我在这里缺少什么吗?

【问题讨论】:

    标签: proxy amazon-ec2 docker


    【解决方案1】:

    您需要使用 HTTP_PROXY 环境变量运行 Docker 守护程序,因为图像的拉取是通过守护程序进行的。如果你使用的是 Ubuntu,这可以通过修改 /etc/init/docker.conf 来完成。

    更新:

    我们现在也正确支持/etc/default/docker,因此现在(在 Ubuntu 和 Debian 上)实现这一点的最佳方法是通过 export http_proxy=... 内的 /etc/default/docker

    【讨论】:

    • 您能否分享更多信息如何在 docker.conf 文件中添加代理设置?我尝试添加 https_proxy=proxy:port /usr/bin/docker -d,但它不起作用。我仍然遇到连接超时。
    【解决方案2】:

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

    sudo service docker restart
    

    应用代理。

    【讨论】:

      【解决方案3】:

      在 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>/
      

      然后重启 docker daemon service docker restart

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-06-09
        • 2021-11-05
        • 2022-07-13
        • 2021-07-26
        • 2019-10-04
        • 2018-11-06
        • 2021-08-18
        相关资源
        最近更新 更多