dockerfile下載依賴找不到元驅(qū)動(dòng) Error: Failed to download metadata for repo 'appstream'

dockerfile下載依賴找不到元驅(qū)動(dòng) 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時(shí),創(chuàng)建了一個(gè)極簡的centOS8系統(tǒng),當(dāng)我想要在容器中安裝一個(gè)鏡像時(shí),告訴我

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

這樣的錯(cuò)誤,無法下載repo的元數(shù)據(jù)

我們進(jìn)入到 /var/log/def.log目錄中查看日志,發(fā)現(xiàn)告訴我們是網(wǎng)絡(luò)的問題

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 百度 發(fā)現(xiàn)是可以ping的通的。那就排除了網(wǎng)絡(luò)的問題

[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已經(jīng)結(jié)束了生命周期,意味著我們update升級新的centOS將不再能夠從官方項(xiàng)目中獲得開發(fā)資源,這意味著我們?nèi)绻胍猽pdate新的資源,就必須要將從vault.centos.org中獲得鏡像進(jìn)行更新

解決問題

找到了問題怎么出現(xiàn)的,就可以針對問題進(jìn)行解決了
第一步:回到/etc/yum.repos.d/文件目錄下

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

第二步 運(yùn)行以下命令

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

大功告成!
當(dāng)然,如果你是想安裝java之類的其他功能包也可以按照這樣的方法,只是更改第四步就可以了。

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

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

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