问题描述:Failed to download metadata for repo ‘appstream‘: Cannot prepare internal mirrorlist:...
打算在centos上运行一个centos8的docker,因为8版官方不再支持,因此需要更换源。
找了很多方案,如解决方案写入到DockerFIle中、wget更新等都没解决。
最后通过以下方案解决了。
首先备份当前的yum仓库配置:
mkdir /etc/yum.repos.d/backup
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup/
选择一个合适的第三方源,比如阿里云、网易等。以下以阿里云为例:
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
清除缓存并生成新的缓存:
yum clean all
yum makecache
安装wget:
yum install wget -y
结果:
Userid : "CentOS (CentOS Official Signing Key) <security@centos.org>"
Fingerprint: 99DB 70FA E1D7 CE22 7FB6 4882 05B5 55B3 8483 C65D
From : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : publicsuffix-list-dafsa-20180723-1.el8.noarch 1/3
Installing : libpsl-0.20.2-6.el8.x86_64 2/3
Installing : wget-1.19.5-10.el8.x86_64 3/3
Running scriptlet: wget-1.19.5-10.el8.x86_64 3/3
Verifying : libpsl-0.20.2-6.el8.x86_64 1/3
Verifying : publicsuffix-list-dafsa-20180723-1.el8.noarch 2/3
Verifying : wget-1.19.5-10.el8.x86_64 3/3
Installed:
libpsl-0.20.2-6.el8.x86_64 publicsuffix-list-dafsa-20180723-1.el8.noarch wget-1.19.5-10.el8.x86_64
Complete!