【发布时间】:2015-06-20 05:57:36
【问题描述】:
我正在尝试使用 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"
有什么想法吗?
更新:
这似乎是 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 vm,我发现了各种半生不熟的解决方案,这些解决方案大多似乎都不起作用。无论我尝试什么,我都无法解析代理服务器的主机名
【问题讨论】:
标签: proxy dns docker virtualbox apt-get