如:
Failed to download metadata for repo 'AppStream'
Error: Failed to download metadata for repo 'AppStream'
或者
Failed to download metadata for repo 'AppStream': Cannot prepare internal mirrorlist: No URLs in mirrorlist.
等等.
替换yum源
cd /etc/yum.repos.d/
mkdir backup && mv *repo backup/
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
或
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
详见阿里云文档, https://help.aliyun.com/document_detail/405635.html?spm=5176.smartservice_service_chat.0.0.712c3f1bBoZ19I
4. 生成缓存
yum makecache
dockerfile文件 添加
# CentOS-8 yum源问题处理
# 删除旧配置
RUN rm -rf /etc/yum.repos.d/*.repo
# 安装源
RUN curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
# 解决源出现 Couldn't resolve host 'mirrors.cloud.aliyuncs.com' 问题
RUN sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
# 生成缓存
RUN yum makecache
# 安装
RUN yum -y install xxx(需要安装的软件)