今天用Docker上线一个Java后端服务器测试,发现使用yum update命令竟然报错:
大概意思就是curl请求不到http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=container和http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=container,得换源了。
首先进入仓库源文件夹下:
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的缓存,并重新生成:
yum clean all && yum makecache
这里需要稍微等待一会...
完成后再次尝试更新软件包:
yum update
完美解决!
补充一下,这个容器不知道为什么没有clear命令,下载一下这个包就好了:
yum install ncurses -y