【发布时间】:2016-08-15 20:38:48
【问题描述】:
我正在使用 Dockerfile 访问我们公司的 Nexus (npm) 服务器以获取“npm install”命令。我看到了:
* Hostname was NOT found in DNS cache
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 216.xxx.xxx.xxx...
* connect to 216.xxx.xxx.xxx port 443 failed: Connection refused
* Failed to connect to nexus.<something>.com port 443: Connection refused
* Closing connection 0
curl: (7) Failed to connect to nexus.<something>.com port 443: Connection refused
我可以解析 www.google.com。我可以从我的本地盒子中点击并使用我们的公司 NPM 注册表。似乎只有我们的内部 dns 名称才是问题所在,并且只有在尝试从 docker 容器内部访问它们时。我在 Google 上搜索过,但无法确定我需要做出哪些更改才能解决此问题。
Dockerfile(我已经修剪了不相关的命令):
FROM node:6.3
RUN curl -k -v https://www.google.com
RUN curl -k -vv https://nexus.<something>.com/repository/npm-all/
到 google.com 的 curl 成功。我们内部 repo 的 curl 失败。
我用命令启动它:
docker build .
/etc/resolv.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.1.1
我正在运行 Ubuntu 15.10。
解决方案
@BMitch 是正确的。通过添加与您的公司网络关联的 dns 服务器地址来修改 /etc/resolv.conf 的内容。对于 Ubuntu 15+(我正在运行 gnome3),您的配置文件将被网络管理器覆盖,因此无法手动编辑。通过网络管理器 gui 进行更改。打开网络设置,选择 DNS 选项卡并添加服务器。
【问题讨论】:
-
你能显示你的 Docker 主机的 /etc/resolv.conf 吗?
-
添加到原始问题中。
标签: docker dns dockerfile