'No URLs in mirrorlist with yum on centos due to appstream

From what I can tell, started this morning from a fresh centos container.

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


Solution 1:[1]

As this question has been closed, and the answers are not the best option, I am writing it here.

Your image or the base image you rely on uses CentOS Linux 8, which has reached EOL.

You should move to use a newer image or if you directly use CentOS Linux 8, switch to another base image.

In case you are forced for now to keep using it. You can switch to use the old repositories and then switch to the CentOS Stream 8 repositories with:

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

dnf update -y; \
dnf --disablerepo '*' --enablerepo extras swap centos-linux-repos centos-stream-repos -y; \
dnf distro-sync -y;

The switch to CentOS Stream 8 is documented in https://www.centos.org/centos-stream/:

CentOS Linux 8 to CentOS Stream 8

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 froblesmartin