简体   繁体   English

Docker无法使用代理连接到Internet

[英]Docker can't connect to the internet from with proxy

I have this Linux box 我有这个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

I have docker running on it (someone else installed it for me, but it seems the configuration files like /etc/default/docker don't exist) 我有docker在上面运行(有人为我安装了它,但是似乎/ etc / default / docker这样的配置文件不存在)

I use a proxy http and https. 我使用代理HTTP和https。
I've added the proxy settings to .bashrc file and .bash_profile and I was able to pull with github. 我已经将代理设置添加到.bashrc文件和.bash_profile中,并且能够使用github进行拉取。 I've also added HTTP_PROXY and the lowercase version (http_proxy) to /etc/default/docker, /etc/environment, /etc/apt/apt.conf, /etc/bash.bashrc and probably others too) 我还添加了HTTP_PROXY和小写版本(http_proxy)到/etc/default/docker、/etc/environment、/etc/apt/apt.conf、/etc/bash.bashrc以及其他可能的文件中)

My proxies are in this format: 我的代理人采用以下格式:

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

If I use wget I can't get anything. 如果我使用wget,我什么也收不到。 Requests time out. 请求超时。

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.

I've looked at the docker documentation and a few SO questions and none solved the issue for me: 我查看了docker文档和一些SO问题,但没有一个问题为我解决了:
Problem of using proxy with wget in Ubuntu 在Ubuntu中将代理与wget一起使用的问题

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

Cannot download Docker images behind a proxy 无法在代理后面下载Docker映像

How do I connect to the internet with docker. 如何使用docker连接到互联网。 Do I need a username and password in the proxy line? 代理行中是否需要用户名和密码?

EDIT 1 编辑1
Got wget to work by adding /root/.wgetrc and putting the proxies in there. 通过添加/root/.wgetrc并将代理放置在其中,wget可以工作。
This didn't work for docker with /root/.dockerrc :( 这不适用于使用/root/.dockerrc的docker :(

This has not been answered for long, but it might help others. 这个问题尚未得到解答很长时间,但可能会对其他人有所帮助。

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

Just passing your proxy as build arguments when building the image does the trick. 只要在构建映像时将代理作为构建参数传递就可以了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM