Linux(CentOS) Docker 安装与配置(报错总结)

前言:(步骤)

# 安装 docker
yum install -y yum-utils
yum-config-manager \
  --add-repo \
  https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce docker-ce-cli containerd.io

# 启动 docker。
systemctl start docker

一、centos8执行yum install -y yum-utils出错

[root@localhost ~]# yum install -y yum-utils
CentOS-8 - AppStream                             25  B/s |  38  B     00:01    
CentOS-8 - Base                                  69  B/s |  38  B     00:00    
Failed to synchronize cache for repo 'AppStream', ignoring this repo.
Failed to synchronize cache for repo 'BaseOS', ignoring this repo.
Last metadata expiration check: 0:11:10 ago on Mon 20 May 2024 06:26:45 AM PDT.
No match for argument: yum-utils
Error: Unable to find a match

①正确解决步骤:
1.#进入配置文件目录

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ll
total 44
-rw-r--r--. 1 root root  731 Aug 13  2019 CentOS-AppStream.repo
-rw-r--r--. 1 root root  712 Aug 13  2019 CentOS-Base.repo
-rw-r--r--. 1 root root  798 Aug 13  2019 CentOS-centosplus.repo
-rw-r--r--. 1 root root 1320 Aug 13  2019 CentOS-CR.repo
-rw-r--r--. 1 root root  668 Aug 13  2019 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  756 Aug 13  2019 CentOS-Extras.repo
-rw-r--r--. 1 root root  338 Aug 13  2019 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  928 Aug 13  2019 CentOS-Media.repo
-rw-r--r--. 1 root root  736 Aug 13  2019 CentOS-PowerTools.repo
-rw-r--r--. 1 root root 1382 Aug 13  2019 CentOS-Sources.repo
-rw-r--r--. 1 root root   74 Aug 13  2019 CentOS-Vault.repo

2.#删除所有的.repo源文件----->很重要

[root@localhost yum.repos.d]# rm *.repo #
rm: remove regular file 'CentOS-AppStream.repo'? y
rm: remove regular file 'CentOS-Base.repo'? y
rm: remove regular file 'CentOS-centosplus.repo'? y
rm: remove regular file 'CentOS-CR.repo'? y
rm: remove regular file 'CentOS-Debuginfo.repo'? y
rm: remove regular file 'CentOS-Extras.repo'? y
rm: remove regular file 'CentOS-fasttrack.repo'? y
rm: remove regular file 'CentOS-Media.repo'? y
rm: remove regular file 'CentOS-PowerTools.repo'? y
rm: remove regular file 'CentOS-Sources.repo'? y
rm: remove regular file 'CentOS-Vault.repo'? y

3.#下载可用的.repo文件

[root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
--2024-05-20 06:54:40--  https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 113.207.38.79, 58.19.152.234, 121.31.228.216, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|113.207.38.79|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2495 (2.4K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’

/etc/yum.repos.d/Ce 100%[===================>]   2.44K  --.-KB/s    in 0s      

2024-05-20 06:54:40 (39.5 MB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [2495/2495]

4.#运行yum makecache生成缓存

[root@localhost yum.repos.d]# yum makecache
CentOS-8.5.2111 - AppStream - mirrors.aliyun.co 3.5 MB/s | 8.4 MB     00:02    
CentOS-8.5.2111 - Base - mirrors.aliyun.com      13 kB/s | 3.9 kB     00:00    
CentOS-8.5.2111 - Extras - mirrors.aliyun.com   2.9 kB/s | 1.5 kB     00:00    
Metadata cache created.

5.#运行yum install -y yum-utils

[root@localhost yum.repos.d]# yum install -y yum-utils

完成!!

②错误步骤:(请勿模仿)

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ll

total 44
-rw-r--r--. 1 root root  731 Aug 13  2019 CentOS-AppStream.repo
-rw-r--r--. 1 root root  712 Aug 13  2019 CentOS-Base.repo
-rw-r--r--. 1 root root  798 Aug 13  2019 CentOS-centosplus.repo
-rw-r--r--. 1 root root 1320 Aug 13  2019 CentOS-CR.repo
-rw-r--r--. 1 root root  668 Aug 13  2019 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  756 Aug 13  2019 CentOS-Extras.repo
-rw-r--r--. 1 root root  338 Aug 13  2019 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  928 Aug 13  2019 CentOS-Media.repo
-rw-r--r--. 1 root root  736 Aug 13  2019 CentOS-PowerTools.repo
-rw-r--r--. 1 root root 1382 Aug 13  2019 CentOS-Sources.repo
-rw-r--r--. 1 root root   74 Aug 13  2019 CentOS-Vault.repo

[root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
--2024-05-20 06:39:37--  https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 113.207.38.116, 113.207.38.79, 113.207.38.80, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|113.207.38.116|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2495 (2.4K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’

/etc/yum.repos.d/Ce 100%[===================>]   2.44K  --.-KB/s    in 0s      

2024-05-20 06:39:38 (66.7 MB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [2495/2495]

[root@localhost yum.repos.d]# yum makecache
Repository AppStream is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository PowerTools is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
CentOS-8 - AppStream                             25  B/s |  38  B     00:01    
CentOS-8.5.2111 - Base - mirrors.aliyun.com     1.7 MB/s | 4.6 MB     00:02    
CentOS-8.5.2111 - Extras - mirrors.aliyun.com   4.3 kB/s |  10 kB     00:02    
Failed to synchronize cache for repo 'AppStream', ignoring this repo.
Metadata cache created.

[root@localhost yum.repos.d]# yum install -y yum-utils
Repository AppStream is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository PowerTools is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
CentOS-8 - AppStream                             24  B/s |  38  B     00:01    
CentOS-8.5.2111 - Base - mirrors.aliyun.com     3.2 kB/s | 3.9 kB     00:01    
CentOS-8.5.2111 - Extras - mirrors.aliyun.com   1.3 kB/s | 1.5 kB     00:01    
Failed to synchronize cache for repo 'AppStream', ignoring this repo.
Error: 
 Problem: package python3-libdnf-0.63.0-3.el8.x86_64 requires libsolv.so.1()(64bit), but none of the providers can be installed
  - package python3-libdnf-0.63.0-3.el8.x86_64 requires libsolvext.so.1()(64bit), but none of the providers can be installed
  - package python3-dnf-4.7.0-4.el8.noarch requires python3-libdnf >= 0.61.1, but none of the providers can be installed
  - cannot install both libsolv-0.7.19-1.el8.x86_64 and libsolv-0.6.35-6.el8.x86_64
  - package yum-utils-4.0.21-3.el8.noarch requires python3-dnf >= 4.2.22, but none of the providers can be installed
  - package rpm-ostree-libs-2018.8-2.el8.0.1.x86_64 requires libsolv.so.0()(64bit), but none of the providers can be installed
  - package rpm-ostree-libs-2018.8-2.el8.0.1.x86_64 requires libsolv.so.0(SOLV_1.0)(64bit), but none of the providers can be installed
  - conflicting requests
  - problem with installed package rpm-ostree-libs-2018.8-2.el8.0.1.x86_64
(try to add '--allowerasing' to command line to replace conflicting packages or '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
 

#运行yum install -y yum-utils又报错--->原因:没有删除所有的.repo源文件

二、成功在CentOS系统上添加Docker的官方仓库

三、启动 docker

[root@localhost ~]# systemctl start docker

查看版本:

[root@localhost ~]# docker version

  • 25
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值