centos一键安装docker出现错误解决教程

Author:

dock一键安装命令出现这样

[root@]# dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

回复这样的问题。
Repository baseos is listed more than once in the configuration
Repository appstream is listed more than once in the configuration
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-epel.repo; Configuration: OptionBinding with id "failovermethod" does not exist
Repository epel is listed more than once in the configuration
CentOS Linux 8 - AppStream 0.0 B/s | 0 B 00:00
Errors during downloading metadata for repository 'appstream':

  • Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock [Could not resolve host: mirrorlist.centos.org]
    Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock [Could not resolve host: mirrorlist.centos.org]

你看到的报错说明 系统还在尝试访问已经下线的 mirrorlist.centos.org,而且 repo 配置里依旧保留了旧的地址,我们得把这些旧的、重复的、带 failovermethod 的 repo 文件彻底清理或禁用掉。

下面给出“一步一命令”的修复流程,照抄即可:


【1】先确认 DNS 能解析外网

ping -c3 8.8.8.8        # 能通就行
ping -c3 vault.centos.org

如果 DNS 不通,可以临时改 /etc/resolv.conf

echo 'nameserver 8.8.8.8' > /etc/resolv.conf

【2】把所有旧的 .repo 统一搬到备份目录

mkdir -p /etc/yum.repos.d/bak
mv /etc/yum.repos.d/CentOS-*.repo /etc/yum.repos.d/bak/
mv /etc/yum.repos.d/epel*.repo     /etc/yum.repos.d/bak/

【3】只保留一个干净的新 Vault 源

cat > /etc/yum.repos.d/CentOS-Vault.repo <<'EOF'

[baseos]

name=CentOS-8-BaseOS baseurl=https://vault.centos.org/8-stream/BaseOS/x86_64/os/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial enabled=1

[appstream]

name=CentOS-8-AppStream baseurl=https://vault.centos.org/8-stream/AppStream/x86_64/os/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial enabled=1 EOF


【4】清理缓存并重建

dnf clean all
dnf makecache

这一步应该不再出现 mirrorlist.centos.org 的解析错误。


【5】再安装 Docker

dnf install -y yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

【6】启动并验证

systemctl enable --now docker
docker run --rm hello-world

关于网页内容
你贴的两个链接 http://mirrorlist.centos.org/... 因为 CentOS 8 官方镜像下线已经 404,所以无论如何都无法解析到有效内容——这并不是网络问题,而是官方服务已关闭。我们无需再尝试访问它,直接用 Vault 镜像即可。


一步步执行



微信扫描下方的二维码阅读本文

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注