docker错误集:CentOS环境

1、报错:bash: vim: command not found

docker运行centos:latest镜像,进去使用vim命令时提示:bash: vim: command not found

解决方案:

直接yum -y install vim


2、报错:Failed to set locale, defaulting to C.UTF-8

原因是因为没有配置正确的语言环境造成的。将该配置文件进行就该即可。

解决方案:

echo "export LC_ALL=en_US.UTF8" >> /etc/profile
source /etc/profile


3、报错:Error: Failed to download metadata for repo ‘appstream’: Cannot prepare internal mirrorlist

报错原因: 从仓库 ‘appstream’ 下载元数据失败:由于镜像列表中没有 URL,不能准备内部镜像列表

在2022年1月31日,CentOS团队终于从官方镜像中移除CentOS 8的所有包。
CentOS 8已于2021年12月31日寿终正非,但软件包仍在官方镜像上保留了一段时间。现在他们被转移到https://vault.centos.org

报错原图:
在这里插入图片描述

解决方案:

cd /etc/yum.repos.d/
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 makecache
yum -y install vim