【发布时间】:2018-08-10 12:00:22
【问题描述】:
我遇到一个问题,在发出 docker build 命令时收到以下错误:-
curl: (6) Could not resolve host: dl.yarnpkg.com
gpg: no valid OpenPGP data found.
这是我的 Dockerbuild 文件
# Base image
FROM ruby:2.5.0
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee
/etc/apt/sources.list.d/yarn.lisT
RUN apt-get update
RUN apt-get install -qq -y build-essential libpq-dev nodejs yarn
在 docker 外部运行时,命令成功完成。
为了解决问题,我尝试了以下方法
- 将 DNS 服务器添加到 /etc/docker/daemon.json - 同样的问题
- 取消注释 /etc/default/docker 中的 DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4" 行 - 相同问题
- 替换我在 /etc/resolv.conf 中本地使用的 DNS 服务器 - 相同的问题。
我已经尝试过来自 Google 和 OpenDNS 的 DNS 服务器,以及多个 ISP,具体取决于我运行命令的位置
笔记本电脑运行 Ubuntu 16:04,Docker 版本为 18.06.0-ce,安装了 build 0ffa825。
使用以下也失败了
FROM ruby:2.5.0
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
导致以下错误
W: Failed to fetch http://deb.debian.org/debian/dists/stretch/InRelease Temporary failure resolving 'deb.debian.org'
W: Failed to fetch http://deb.debian.org/debian/dists/stretch-updates/InRelease Temporary failure resolving 'deb.debian.org'
W: Failed to fetch http://security.debian.org/dists/stretch/updates/InRelease Temporary failure resolving 'security.debian.org'
W: Some index files failed to download. They have been ignored, or old ones used instead.
所以我知道这不仅仅是 dl.yarnpkg.com 主机的问题。
使用 no-cache 选项运行 docker build 命令没有区别。
【问题讨论】:
-
如果你在容器外的 docker 主机上运行
nslookup dl.yarnpkg.com 8.8.8.8会发生什么? -
服务器:8.8.8.8 地址:8.8.8.8#53 非权威回答:名称:dl.yarnpkg.com 地址:104.16.60.173 名称:dl.yarnpkg.com 地址:104.16.63.173 名称:dl.yarnpkg.com 地址:104.16.61.173 名称:dl.yarnpkg.com 地址:104.16.62.173 名称:dl.yarnpkg.com 地址:104.16.59.173 正如我所说,我尝试了不同的 DNS 提供商,问题出现在他们都。
-
我也尝试在 ubuntu dns 设置中禁用 dnsmasq....不走运,...
-
你是不是在修改了 daemon.json 后重新加载了 docker 引擎?如果你运行
docker run -it --rm alpine cat /etc/resolv.conf和docker run -it --rm alpine nslookup dl.yarnpkg.com会发生什么? -
# 由 resolvconf(8) 生成的 glibc 解析器 (3) 的动态 resolv.conf(5) 文件 # 不要手动编辑此文件 -- 您的更改将被覆盖 nameserver 8.8.8.8 nameserver 8.8 .4.4 nameserver 192.168.0.1 nameserver 208.67.222.222 search Home nameserver 8.8.8.8 nameserver 8.8.4.4
标签: docker