因为 CentOS 8 已经结束生命周期,原来的镜像源不可用了。我们需要将镜像源改为 CentOS 8 的替代源。
在容器中运行以下命令:
首先备份原有的源
cd /etc/yum.repos.d/
mkdir backup
mv *.repo backup/
创建新的源文件
cat > /etc/yum.repos.d/CentOS-Base.repo << ‘EOF’
[BaseOS]
name=CentOS- r e l e a s e v e r − B a s e b a s e u r l = h t t p s : / / m i r r o r s . a l i y u n . c o m / c e n t o s − v a u l t / 8.5.2111 / B a s e O S / releasever - Base baseurl=https://mirrors.aliyun.com/centos-vault/8.5.2111/BaseOS/ releasever−Basebaseurl=https://mirrors.aliyun.com/centos−vault/8.5.2111/BaseOS/basearch/os/
gpgcheck=0
enabled=1
[AppStream]
name=CentOS- r e l e a s e v e r − A p p S t r e a m b a s e u r l = h t t p s : / / m i r r o r s . a l i y u n . c o m / c e n t o s − v a u l t / 8.5.2111 / A p p S t r e a m / releasever - AppStream baseurl=https://mirrors.aliyun.com/centos-vault/8.5.2111/AppStream/ releasever−AppStreambaseurl=https://mirrors.aliyun.com/centos−vault/8.5.2111/AppStream/basearch/os/
gpgcheck=0
enabled=1
[extras]
name=CentOS- r e l e a s e v e r − E x t r a s b a s e u r l = h t t p s : / / m i r r o r s . a l i y u n . c o m / c e n t o s − v a u l t / 8.5.2111 / e x t r a s / releasever - Extras baseurl=https://mirrors.aliyun.com/centos-vault/8.5.2111/extras/ releasever−Extrasbaseurl=https://mirrors.aliyun.com/centos−vault/8.5.2111/extras/basearch/os/
gpgcheck=0
enabled=1
[PowerTools]
name=CentOS- r e l e a s e v e r − P o w e r T o o l s b a s e u r l = h t t p s : / / m i r r o r s . a l i y u n . c o m / c e n t o s − v a u l t / 8.5.2111 / P o w e r T o o l s / releasever - PowerTools baseurl=https://mirrors.aliyun.com/centos-vault/8.5.2111/PowerTools/ releasever−PowerToolsbaseurl=https://mirrors.aliyun.com/centos−vault/8.5.2111/PowerTools/basearch/os/
gpgcheck=0
enabled=1
EOF
清理缓存并更新
dnf clean all
dnf makecache
现在可以安装软件包了
dnf install -y dnf-plugins-core