Dockerfile download dependency cannot find meta driver 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
I created a minimalist centOS8 system when deploying my dockerfile, and when I want to install an image in a container, tell me
Error: Failed to download metadata for repo ‘appstream’:
Such an error, unable to download the metadata of the repo
We entered the /var/log/def.log directory to view the log and found that it was a network problem.
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
I tried to ping Baidu and found that it can be pinged. That ruled out the network problem
[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
I see in the official documentation
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.
The above said that from the end of 2021, the life cycle of centos8 linux has ended, which means that we will no longer be able to obtain development resources from the official project when we update and upgrade the new centOS, which means that if we want to update new resources, we must update the resources from Get mirrors at vault.centos.org for updates
Solve the problem
If you find out how the problem occurred, you can solve the problem.
Step 1: Go back to the /etc/yum.repos.d/ file directory
cd ~
cd /etc/yum.repos.d/
The second step is to run the following command
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-*
The third step, update
yum update -y
The fourth step, install git
yum install git
You're done!
Of course, if you want to install other functional packages such as java, you can also follow this method, just change the fourth step.