今天使用 Docker build 命令时,遇到了一种错误
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
网友提供了很多方案:
1、关闭防火墙
docker stop firewall.service
执行后告知,我并没有开启防火墙,哈哈
2、CentOS版本的问题
在2022年1月31日,CentOS团队终于从官方镜像中移除CentOS 8的所有包。
CentOS 8已于2021年12月31日寿终正非,但软件包仍在官方镜像上保留了一段时间。现在他们被转移到https://vault.centos.org;
执行命令:
sudo dnf install -y curl policycoreutils openssh-server perl
but··提示: -bash: dnf: 未找到命令 ,OK,遇贼杀贼,yum命令
yum -y install dnf
然后继续执行build 还是报一样的错!!!
然后我就仔细研究了下build执行的 dockerfile文本,最终发现原因是,dockerfile中 run命令没有执行成功导致
The command '/bin/sh -c yum -y install net-tools' returned a non-zero code: 1
然后我删除build 中的run命令,单独拿出来执行执行,
yum -y install net-tools
然后再执行 docker build ,终于解决了!