我正在尝试使用 Docker 在企业代理服务器后面设置一个开发环境。尽我所能,我无法让 docker 容器与代理服务器通信。
代理服务器和 apt-get 在主机(Ubuntu 12.04)上工作正常
Dockerfile 中完成的第一件事是尝试设置代理变量:
FROM ubuntu
RUN echo 'Acquire::http { Proxy "http://my.proxy.net:8000"; };' >> /etc/apt/apt.conf.d/01proxy
ENV HTTP_PROXY http://my.proxy.net:8000
ENV http_proxy http://my.proxy.net:8000
ENV HTTPS_PROXY https://my.proxy.net:8000
ENV https_proxy https://my.proxy.net:8000
RUN apt-get update && apt-get install -y build-essential
它很好地提取了图像,设置了变量,但是当它到达 apt-get update 时,它会尝试一段时间,然后失败:
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/InRelease
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/InRelease
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-security/InRelease
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/Release.gpg Could not resolve 'my.proxy.net'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/Release.gpg Could not resolve 'my.proxy.net'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-security/Release.gpg Could not resolve 'my.proxy.net'
W: Some index files failed to download. They have been ignored, or old ones used instead.
我设置的这些变量与主机 Linux 安装一致(VirtualBox 上的 Ubuntu 12.04,如果重要的话)
我还设置了 /etc/default/docker:
export http_proxy="http://my.proxy.net:8000"
export http_proxy="https://my.proxy.net:8000"
有什么想法吗?
UPDATE:
看起来这是 DNS 的问题,不一定是代理服务器的问题。主机 /etc/resolve.conf 包含:
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.0.1
search dhcp.mycompany.com
主机是一个在 Windows 7 机器上运行的 virtualbox 虚拟机,我发现了各种不成熟的解决方案,但大多数似乎不起作用。无论我如何尝试,我都无法让它解析代理服务器的主机名