我遇到了一个问题,当我执行docker build命令时,会收到以下错误提示:
这是我的Docker构建文件。
导致以下错误。
curl: (6) Could not resolve host: dl.yarnpkg.com
gpg: no valid OpenPGP data found.
这是我的Docker构建文件。
# 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,构建版本为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命令没有任何区别。
nslookup dl.yarnpkg.com 8.8.8.8
,会发生什么? - BMitch非权威答案: 名称: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提供商,但问题仍然存在。 - user2099762docker run -it --rm alpine cat /etc/resolv.conf
和docker run -it --rm alpine nslookup dl.yarnpkg.com
会发生什么? - BMitch由resolvconf(8)生成的用于glibc resolver(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 - user2099762