docker - 通过 Oracle VM 和 cntlm 代理从 docker 内部访问 Internet
问题描述
如何在 Ubuntu 16.04 上通过 Oracle VM (5.2.4) 和 Windows 7 上的 cntlm 代理从 docker 内部进行 Internet http 调用?
代理已配置(IP 192.168.56.1,VM 主机)。在 Ubuntus Firefox 中或使用命令行中的 wget 可以成功访问 Internet。
Docker CE (17.12.0-ce) 配置为也使用代理 ip:/etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://192.168.56.1:3128/"
Environment="HTTPS_PROXY=http://192.168.56.1:3128/"
我可以成功提取的所有 docker 图像。
只有 docker 容器内的 wget 或任何安装调用失败。
许多帮助页面稍后,我不知道更多。我的尝试:
docker run --name test --network host -e "https_proxy=https://192.168.56.101:3128" -it alpine:latest wget https://www.web.de
wget: bad address 'www.web.de'
docker run --name test --dns 8.8.8.8 -e "https_proxy=https://192.168.56.101:3128" -it alpine:latest wget https://www.web.de
wget: bad address 'www.web.de'
docker run --name test -e "https_proxy=https://192.168.56.101:3128" -it alpine:latest wget https://www.web.de
wget: bad address 'www.web.de'
docker run --name test --network host --dns 8.8.8.8 -e "https_proxy=https://192.168.56.101:3128" -it alpine:latest wget https://www.web.de
wget: bad address 'www.web.de'
所有打印的调用也带有“http”并且没有代理环境。
对我的另一个想法?
解决方案
For docker to work with CNTLM it is important to set
Gateway yes
in the CNTLM-Config.
I run CNTLM directly on the VM and set all proxys within the container to http://172.17.0.1:3128.
For the sake of completeness, please set all Proxy-Env in docker run:
PROXY_DOCKER="http://172.17.0.1:3128/"
docker run -e HTTP_PROXY=${PROXY_DOCKER} -e http_proxy=${PROXY_DOCKER} -e HTTPS_PROXY=${PROXY_DOCKER} -e https_proxy=${PROXY_DOCKER} ...
推荐阅读
- c++ - 为什么“do while”循环一直退出,即使条件评估为假?
- java - 替代在控制台中手动编写
- python-3.x - 我如何在 python 的帮助下玩棋盘
- c++ - 在 boost multi_index 容器中,是否定义了“默认索引”?
- sed - 打印行号的行范围
- azure - Azure DevOps 管道测试失败......但我如何轻松识别哪些测试?
- arrays - 从数组中计算特定值 - 只能使用数组中的一个数字
- c# - 如何配置 .net core api 中使用的默认 XmlSerializer
- r - 如何计算所有行中列中值的实例数?
- cmake - 如何为 Synology NAS 交叉编译 neovim