docker-ce-23.0.5-1.el7.x86_64.rpm: [Errno -1] 软件包与预期下载的不符

使用了阿里云服务器ECS上部署Docker的方法:

部署并使用Docker(CentOS 8)

前面几步都很顺利,使用阿里云镜像后解决了国外源连接超时的问题

但是在最后一步在安装docker时

[root@foo liang]# yum clean all
已加载插件:fastestmirror
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
正在清理软件源: base docker-ce-stable epel extras nodesource updates
Cleaning up list of fastest mirrors

[root@foo liang]# yum makecache
已加载插件:fastestmirror
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Determining fastest mirrors
 \* epel: mirrors.aliyun.com
事务概要
=======================================================================================================================
安装  2 软件包 (+3 依赖软件包)
升级 82 软件包
移除  2 软件包
总下载量:270 M
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for docker-ce-stable
No Presto metadata available for updates
(1/87): bind-libs-9.11.4-26.P2.el7_9.13.x86_64.rpm                       | 158 kB 00:00:00   
(2/87): bind-export-libs-9.11.4-26.P2.el7_9.13.x86_64.rpm                    | 1.1 MB 00:00:01   
(3/87): bind-license-9.11.4-26.P2.el7_9.13.noarch.rpm                      | 92 kB 00:00:00   
(4/87): bind-utils-9.11.4-26.P2.el7_9.13.x86_64.rpm                       | 262 kB 00:00:00   
(5/87): bind-libs-lite-9.11.4-26.P2.el7_9.13.x86_64.rpm                     | 1.1 MB 00:00:01   
(6/87): ca-certificates-2022.2.54-74.el7_9.noarch.rpm                      | 911 kB 00:00:00   
(7/87): brotli-1.0.9-10.el7.x86_64.rpm                             | 309 kB 00:00:00   
(8/87): diffutils-3.3-6.el7_9.x86_64.rpm                            | 322 kB 00:00:01   
(9/87): docker-buildx-plugin-0.10.4-1.el7.x86_64.rpm                      | 12 MB 00:00:13   
docker-ce-23.0.5-1.el7.x86_64. FAILED                      
https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/stable/Packages/docker-ce-23.0.5-1.el7.x86_64.rpm: [Errno -1] 软件包与预期下载的不符。建议:运行 yum --enablerepo=docker-ce-stable clean metadata
正在尝试其它镜像。

img

发现 docker-ce.repo 文件中,默认安装的 docker-ce-stable 中,enabled 值与其他仓库不一致,其他仓库均为 0,而 docker-ce-stable 中的enabled值为 1

vim /etc/yum.repos.d/docker-ce.repo

改为 0 故障排除