linux - Docker 无法使用代理连接到互联网

标签 linux docker wget http-proxy

我有这个Linux盒子

$ uname -a
Linux TOCWgfi7IC 2.6.32-504.el6.x86_64 #1 SMP Tue Sep 16 01:56:35 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux

我有docker在上面运行(别人帮我安装的,但是好像/etc/default/docker这样的配置文件不存在)

我使用代理 http 和 https。
我已经将代理设置添加到 .bashrc 文件和 .bash_profile 并且我能够使用 github 进行拉取。我还将 HTTP_PROXY 和小写版本 (http_proxy) 添加到/etc/default/docker、/etc/environment、/etc/apt/apt.conf、/etc/bash.bashrc,可能还有其他)

我的代理采用这种格式:

http_proxy=http://proxyprd.sss.com:8080
https_proxy=https://proxyprd.sss.com:8080

如果我使用 wget,我什么也得不到。请求超时。

sudo wget https://index.docker.io/v1
--2015-07-07 13:13:33--  https://index.docker.io/v1
Resolving index.docker.io... 54.174.141.60, 54.210.36.116, 54.152.41.71
Connecting to index.docker.io|54.174.141.60|:443...
failed: Connection timed out.

我查看了 docker 文档和一些 SO 问题,但没有一个能为我解决问题:
Problem of using proxy with wget in Ubuntu

https://docs.docker.com/articles/systemd/#http-proxy

Cannot download Docker images behind a proxy

如何使用 docker 连接到互联网。我需要在代理行中输入用户名和密码吗?

编辑 1
通过添加/root/.wgetrc 并将代理放在那里让 wget 工作。
这对带有/root/.dockerrc 的 docker 不起作用:(

最佳答案

这个问题很久没有得到解答,但它可能对其他人有帮助。

docker build --build-arg http_proxy=http://host:port --build-arg https_proxy=https://host:port -t dwp_service:0.1 dwp_services/

只需在构建图像时将您的代理作为构建参数传递即可。

关于linux - Docker 无法使用代理连接到互联网,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31275395/

相关文章:

linux - 如何让我的 VPS 开始使用通过 HostMonster 购买的额外磁盘空间?

java - Kafka + Spring Boot + Docker Compose - 接收重复消息

docker - 如何在不使用docker撰写内容的情况下,让docker容器通过HTTP与主机通信?

.htaccess - 带有密码保护站点 (.htaccess) 的 Cronjob

bash - 如何获取wget下载的文件的文件名

java - 如何让我的目录为将由我的 Java 程序创建的脚本文件提供可执行权限?

与Linux中的内存映射设备通信

linux - 目录中的子目录数量?

docker - docker swarm部署过程进行时如何获取详细日志?

php - 无法从 cron 运行 php 脚本