问候女士们先生们,

如果你找到这篇文章,你很可能遇到了这个令人讨厌的错误:

Step 3/8 : RUN apt-get update && apt-get install gcc python3-dev mariadb-client mariadb-server -y
 ---> Running in 7adba5657671
Err:1 http://deb.debian.org/debian buster InRelease
  Temporary failure resolving 'deb.debian.org'
Err:2 http://security.debian.org/debian-security buster/updates InRelease
  Temporary failure resolving 'security.debian.org'
Err:3 http://deb.debian.org/debian buster-updates InRelease
  Temporary failure resolving 'deb.debian.org'
Reading package lists...
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.
Reading package lists...
Building dependency tree...
Reading state information...
Package python3-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'python3-dev' has no installation candidate
E: Unable to locate package mariadb-client
E: Unable to locate package mariadb-server
ERROR: Service 'process-test-results' failed to build : The command '/bin/sh -c apt-get update && apt-get install gcc python3-dev mariadb-client mariadb-server -y' returned a non-zero code: 100

进入全屏模式 退出全屏模式

它很可能在 docker build 或 docker-compose build 期间弹出。

您试图弄清楚,但 Google 和 StackOverFlow 并没有给您太多的工作机会。我知道,我去过那里。

让我们运行以下命令:

 cat /etc/resolv.conf

进入全屏模式 退出全屏模式

如果这就是你所拥有的:

# Please ignore all the lines that start with a hash symbol
nameserver 127.0.0.53

进入全屏模式 退出全屏模式

你来对地方了。显然,这里有一个与 Docker 和 DNS 172.0.0.53相关的开放错误。

您最有可能使用预装 systemd 的 Ubuntu 18.04 / 20.04,其中 .. 还包含systemd-resolved,这就是它设置为 nameserver 127.0.0.53 的原因。

基本上,在构建过程中,一个 docker 容器正在获取该 DNS 并尝试在容器中使用它。但它不能。

[图像](https://res.cloudinary.com/practicaldev/image/fetch/s--C4Pdp_gI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads .s3.amazonaws.com/uploads/articles/x7codv53o2yoahsm194x.png)

好吧,现在当我们_sort__知道问题出在哪里时,我们终于可以解决它了。

在开始之前,请确保您知道自己在做什么。弄乱您的 DNS 可能会使您的主机无法访问互联网,这真的很不方便。_

无论如何,如果发生这种情况,您最好检查 /etc/resolv.conf 并确保它有以下几行:

nameserver 8.8.8.8
nameserver 8.8.4.4

进入全屏模式 退出全屏模式

1.停止并禁用systemd-resolved

sudo systemctl disable systemd-resolved
sudo systemctl stop systemd-resolved

进入全屏模式 退出全屏模式

1.设置网络管理器识别systemd-resolved为禁用

vim /etc/NetworkManager/NetworkManager.conf
# And then change dns to default. ex:
# dns=default

进入全屏模式 退出全屏模式

  1. 删除旧的 /etc/resolv.conf 文件
rm /etc/resolv.conf

进入全屏模式 退出全屏模式

1.重启网络管理器

sudo systemctl restart NetworkManager

进入全屏模式 退出全屏模式

1.使用dnsmasq将google的DNS服务器添加到/etc/resolv.conf中,因为不能直接修改

sudo vim /etc/dnsmasq.conf
# Add to the end of the file:
server=8.8.8.8
server=8.8.4.4

进入全屏模式 退出全屏模式

Logo

云原生社区为您提供最前沿的新闻资讯和知识内容

更多推荐