dockerfile下载依赖找不到元驱动 Error: Failed to download metadata for repo 'appstream'

dockerfile下载依赖找不到元驱动 Error: Failed to download metadata for repo 'appstream'

[root@415b549933f7 /]# yum install git
Failed to set locale, defaulting to C.UTF-8
CentOS Linux 8 - AppStream                                                                                  48  B/s |  38  B     00:00
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist

我在部署我的dockerfile时,创建了一个极简的centOS8系统,当我想要在容器中安装一个镜像时,告诉我

Error: Failed to download metadata for repo 'appstream':

这样的错误,无法下载repo的元数据

我们进入到 /var/log/def.log目录中查看日志,发现告诉我们是网络的问题

dnf.exceptions.RepoError: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
2022-06-17T08:09:29+0000 CRITICAL Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist

我尝试了一下ping 百度 发现是可以ping的通的。那就排除了网络的问题

[root@415b549933f7 log]# ping baidu.com
PING baidu.com (198.18.0.122) 56(84) bytes of data.
64 bytes from 198.18.0.122 (198.18.0.122): icmp_seq=1 ttl=37 time=1.01 ms
64 bytes from 198.18.0.122 (198.18.0.122): icmp_seq=2 ttl=37 time=2.02 ms
64 bytes from 198.18.0.122 (198.18.0.122): icmp_seq=3 ttl=37 time=0.890 ms
64 bytes from 198.18.0.122 (198.18.0.122): icmp_seq=4 ttl=37 time=1.37 ms
64 bytes from 198.18.0.122 (198.18.0.122): icmp_seq=5 ttl=37 time=0.808 ms
^C
--- baidu.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4062ms
rtt min/avg/max/mdev = 0.808/1.218/2.018/0.444 ms

我在官方文档看到

CentOS Linux 8 will reach End Of Life (EOL) on December 31st, 2021. Here’s what that means.

In line with the EOL of previous releases, we will NOT be automatically migrating anyone to the next version (which is CentOS Stream 8 in this case).

We will be shipping a rebuild of Red Hat Enterprise Linux (RHEL) 8.5 once it is released, even if that means that this is released slightly after the EOL date.

上面说从2021年底centos8 linux已经结束了生命周期,意味着我们update升级新的centOS将不再能够从官方项目中获得开发资源,这意味着我们如果想要update新的资源,就必须要将从vault.centos.org中获得镜像进行更新

解决问题

找到了问题怎么出现的,就可以针对问题进行解决了
第一步:回到/etc/yum.repos.d/文件目录下

cd ~
cd /etc/yum.repos.d/

第二步 运行以下命令

sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*

sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*

第三步,更新

yum update -y

第四步,安装git

yum install git

大功告成!
当然,如果你是想安装java之类的其他功能包也可以按照这样的方法,只是更改第四步就可以了。

你可能感兴趣的:(dockerfile下载依赖找不到元驱动 Error: Failed to download metadata for repo 'appstream')