问题描述
我正在 AWS Workspaces 中设置一个新的开发环境,我注意到当我去运行 docker build
时,我收到以下错误:
---> Running in d18733d53c16
W: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease Temporary failure resolving 'deb.debian.org'
W: Failed to fetch http://security.debian.org/debian-security/dists/buster/updates/InRelease Temporary failure resolving 'security.debian.org'
W: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/InRelease Temporary failure resolving 'deb.debian.org'
W: Some index files Failed to download. They have been ignored,or old ones used instead.
Reddit 上有人提到这是一个已知问题,但 AWS 文档似乎没有提到这个问题,我在网上找不到更多信息。
这只是一个标准的 Docker 文件,已经使用了大约一年,没有出现任何问题。适用于 Linux 的 AWS Workspaces 似乎正在发生。
解决方法
在执行其他任何操作之前,我终于能够通过在顶部的 Dockerfile
中添加 DNS 条目来解决此问题。
例如:
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - && \
apt-get update -qq && \
apt-get upgrade -y && \
变成:
RUN echo "nameserver 1.1.1.1" > /etc/resolv.conf && \
echo "nameserver 8.8.8.8" >> /etc/resolv.conf && \
curl -sL https://deb.nodesource.com/setup_12.x | bash - && \
apt-get update -qq && \
apt-get upgrade -y && \
现在一切都很好。