docker的centos容器使用yum报错

简介: docker的centos容器使用yum报错

错误描述

学习docker过程中,基于 centos 镜像自定义新的镜像。拉取一个Centos镜像,并运行容器,容器安装vim,报错了。

报错:Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist

问题分析

✨第一种可能的情况便是网络连接问题。检查是否可以连接外部网络,可以使用 ping baidu.com 查看是否有丢包情况。如果丢包,则进一步检查网络连接是否正常;如果没有丢包,继续阅读下文

✨那么第二种情况,便是 CentOS 已经停止维护的问题。2020 年 12 月 8 号,CentOS 官方宣布了停止维护 CentOS Linux 的计划,并推出了 CentOS Stream 项目,CentOS Linux 8 作为 RHEL 8 的复刻版本,生命周期缩短,于 2021 年 12 月 31 日停止更新并停止维护(EOL),更多的信息可以查看 CentOS 官方公告。如果需要更新 CentOS,需要将镜像从 mirror.centos.org 更改为 vault.centos.org

解决方案

🥎那么针对上面提到的第二种情况,给出的解决方法如下:

🔔 首先,进入到 yum 的 repos 目录

cd /etc/yum.repos.d/

🔔其次,修改 centos 文件内容

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-*

🔔 然后,生成缓存更新(第一次更新,速度稍微有点慢,耐心等待 2min 左右)

yum makecache

🔔 最后,运行 yum update 并重新安装 vim

yum update -y
yum -y install vim

参考

https://blog.csdn.net/weixin_43252521/article/details/124409151

目录
相关文章
|
1月前
|
应用服务中间件 Linux nginx
Docker镜像-手动制作yum版nginx镜像
这篇文章介绍了如何手动制作一个基于CentOS 7.6的Docker镜像,其中包括下载指定版本的CentOS镜像,创建容器,配置阿里云软件源,安装并配置nginx,自定义nginx日志格式和web页面,最后提交镜像并基于该镜像启动新容器的详细步骤。
104 21
Docker镜像-手动制作yum版nginx镜像
|
7天前
|
Docker 容器
centos7.3之安装docker
centos7.3之安装docker
|
1月前
|
存储 Linux Docker
CentOS 7.6安装Docker实战案例及存储引擎和服务进程简介
关于如何在CentOS 7.6上安装Docker、介绍Docker存储引擎以及服务进程关系的实战案例。
92 3
CentOS 7.6安装Docker实战案例及存储引擎和服务进程简介
|
1月前
|
应用服务中间件 Linux nginx
Docker镜像-基于DockerFile制作yum版nginx镜像
本文介绍了如何使用Dockerfile制作一个基于CentOS 7.6.1810的yum版nginx镜像,并提供了详细的步骤和命令。
75 20
|
3天前
|
缓存 Linux 开发工具
CentOS7 安装KDE报错的解决方法:Loaded plugins:fastestmirror,langpacks There is no installed group.
CentOS7 安装KDE报错的解决方法:Loaded plugins:fastestmirror,langpacks There is no installed group.
10 0
|
3天前
|
Linux 开发工具 数据安全/隐私保护
CentOS7报错:“xxx is not in the sudoers file. This incident will be reported“解决方法
CentOS7报错:“xxx is not in the sudoers file. This incident will be reported“解决方法
|
6天前
|
Linux Shell Python
centos执行pip3 install etcd3报错
centos执行pip3 install etcd3报错
|
2月前
|
存储 关系型数据库 Linux
在CentOS 7上安装和使用Docker的方法
在CentOS 7上安装和使用Docker的方法
173 1
|
1月前
|
Linux
centos使用阿里的yum源
centos使用阿里的yum源
|
2月前
|
缓存 Linux 网络安全
解决 CentOS 7 官方 yum 仓库无法使用的最佳实践
【8月更文挑战第18天】若 CentOS 7 的官方 YUM 仓库无法使用,可按以下步骤解决: 1. **检查网络连接**: - 确认服务器能正常上网,可通过访问外部网站或网络诊断测试。 - 检查防火墙设置,避免其阻挡 YUM 的网络访问。 2. **检查 YUM 配置**: - 核实 `/etc/yum.repos.d/` 下的 `CentOS-Base.repo` 文件中仓库地址正确无误。 - 确认配置文件内的 `enabled` 选项设为 `1` 以启用仓库。
579 0
下一篇
无影云桌面