docker容器內(nèi)更換centos8 yum源

問題描述:Failed to download metadata for repo ‘a(chǎn)ppstream‘: Cannot prepare internal mirrorlist:...

打算在centos上運(yùn)行一個(gè)centos8的docker,因?yàn)?版官方不再支持,因此需要更換源。
找了很多方案,如解決方案寫入到DockerFIle中、wget更新等都沒解決。
最后通過以下方案解決了。

首先備份當(dāng)前的yum倉(cāng)庫(kù)配置:

mkdir /etc/yum.repos.d/backup
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup/

選擇一個(gè)合適的第三方源,比如阿里云、網(wǎng)易等。以下以阿里云為例:

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

結(jié)果:

 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!
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容