CentOS使用中遇到的问题-Loadedplugins:fastestmirror

在centOS系统中,安装docker命令的时候报错

 yum -y install docker
Loaded plugins: fastestmirror, langpacks
You need to be root to perform this command.

 解决办法如下

fastestmirror是yum的一个加速插件,这里是插件提示信息是插件不能用了。

不能用就先别用呗,禁用掉,先yum了再说。

1.修改插件的配置文件

# vi  /etc/yum/pluginconf.d/fastestmirror.conf  

[main]
enabled=1
verbose=0
always_print_best_host = true
socket_timeout=3
#  Relative paths are relative to the cachedir (and so works for users as well
# as root).
hostfilepath=timedhosts.txt
maxhostfileage=10
maxthreads=15
#exclude=.gov, facebook
#include_only=.nl,.de,.uk,.ie

 

enabled = 1//由1改为0,禁用该插件

...............................

2.修改yum的配置文件

# vi /etc/yum.conf

[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release

plugins=1//改为0,不使用插件

........................

你遇到的错误是: ``` File contains no section headers. file: file:///etc/yum.repos.d/CentOS-Base.repo, line: 1 '<!DOCTYPE html>\n' ``` --- ### 🔍 错误原因: 你使用 `curl` 从 `https://mirrors.aliyun.com/repo/Centos-vault-7.9.repo` 下载的文件 **并不是一个合法的 `.repo` 文件**,而是一个 **HTML 页面(可能是 404 页面)**。这说明你访问的 URL 并没有返回正确的 YUM 源配置文件。 --- ### ✅ 正确的镜像源地址: 阿里云的 CentOS Vault 源地址格式应为: ``` https://mirrors.aliyun.com/repo/Centos-{版本}.repo ``` 对于 CentOS 7.9,推荐使用: ``` https://mirrors.aliyun.com/repo/Centos-7.repo ``` 而不是 `Centos-vault-7.9.repo`,因为该路径不存在,返回的是 404 页面(HTML)。 --- ### ✅ 修改后的 Dockerfile 示例: ```dockerfile FROM centos:7 RUN mkdir /repos && \ mv /etc/yum.repos.d/* /repos && \ curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo && \ yum clean all && \ yum makecache && \ yum install -y nginx && \ systemctl enable nginx ``` --- ### ✅ 验证源文件是否正确: 你可以在容器中手动测试是否能下载正确的 `.repo` 文件: ```bash docker run -it --rm centos:7 /bin/bash curl -v https://mirrors.aliyun.com/repo/Centos-7.repo ``` 确保输出是 `[repository]` 风格的 `.repo` 文件内容,而不是 HTML 页面。 --- ### ✅ 其他可用国内源(可选): #### 1. 清华大学镜像源: ```dockerfile RUN curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.tuna.tsinghua.edu.cn/repo/files/CentOS7-Base-163.repo ``` #### 2. 网易镜像源(已逐步下线,不推荐) --- ### ✅ 最终构建命令: ```bash docker build -t nginx . ``` --- ### 🧪 附加建议: - 如果你仍然遇到网络问题,可以尝试使用 `--network host` 构建: ```bash docker build --network host -t nginx . ``` - 确保宿主机可以访问 `mirrors.aliyun.com`: ```bash curl -v https://mirrors.aliyun.com/repo/Centos-7.repo ``` ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值