我遇到一个问题,在发出 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,内部版本 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 命令没有什么区别。