温馨提示:本文翻译自stackoverflow.com,查看原文请点击:ubuntu - Docker: Temporary failure resolving 'deb.debian.org'
debian docker nginx ubuntu

ubuntu - Docker:解决“ deb.debian.org”的临时故障

发布于 2020-08-15 05:20:07

我有一个Ubuntu服务器使用Docker部署Rails应用程序我已经为应用程序设置了Dockerfile,现在我想查看其容器中conf。nginx

我运行以下命令以nginx交互方式启动容器:

docker run -i -t nginx:latest /bin/bash

现在,我正在尝试安装nano编辑器,以便使用以下命令查看nginx配置(nginx.conf的配置

apt-get update
apt-get install nano
export TERM=xterm

但是,当我运行第一个命令时apt-get update,出现以下错误:

Err:1 http://security.debian.org/debian-security buster/updates InRelease
  Temporary failure resolving 'security.debian.org'
Err:2 http://deb.debian.org/debian buster InRelease                  
  Temporary failure resolving 'deb.debian.org'
Err:3 http://deb.debian.org/debian buster-updates InRelease
  Temporary failure resolving 'deb.debian.org'
Reading package lists... Done    
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.

我已经很好地检查了它与网络连接无关。我需要一些帮助。谢谢。

查看更多

提问者
Promise Preston
被浏览
1.4k
Promise Preston 2020-05-03 06:58

这是我解决的方法

以交互方式启动应用程序的docker容器,在我的情况下,它是一个nginx容器:

docker run -i -t nginx:latest /bin/bash

运行以下命令以授予对该文件角色的read权限othersresolv.conf

chmod o+r /etc/resolv.conf

注意:如果在主机(Ubuntu Linux OS)上而不是在Docker容器上遇到此问题,请sudo在主机终端中运行添加到它的相同命令

sudo chmod o+r /etc/resolv.conf

运行此命令后,请尝试退出bash交互式终端:

exit

然后打开一个新的bash交互式终端并再次运行命令:

apt-get update
apt-get install nano
export TERM=xterm

现在一切正常。

在Digital Ocean上对此的引用:Apt错误:解决“ deb.debian.org”的临时故障

就这样。

我希望这有帮助