Docker详细安装步骤,处理cannot install the best candidate for the job

一、安装依赖
执行命令 sudo yum install -y yum-utils

[root@iZbp15rmf8lyj2yhq136ebZ ~]# sudo yum install -y yum-utils
Loaded plugins: fastestmirror
Determining fastest mirrors
base | 3.6 kB 00:00:00
epel | 5.3 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/3): epel/x86_64/updateinfo | 1.0 MB 00:00:00
(2/3): epel/x86_64/primary_db | 6.9 MB 00:00:00
(3/3): updates/7/x86_64/primary_db | 5.8 MB 00:00:00
Resolving Dependencies
--> Running transaction check


Installed:
yum-utils.noarch 0:1.1.31-52.el7

Dependency Installed:
libxml2-python.x86_64 0:2.9.1-6.el7_2.3 python-chardet.noarch 0:2.2.1-3.el7
python-kitchen.noarch 0:1.1.1-5.el7

Complete!


二、指定docker 远程仓库
执行命令 sudo yum-config-manager --add-repo https://download.docker.com/linux/cent

[root@iZbp15rmf8lyj2yhq136ebZ ~]# sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo

三、没有可用软件包docker-ce
现在执行 如下命令来进行docker的安装

yum install docker-ce
但不幸的是。。。
安装中可能会遇到这个问题

没有可用软件包 docker-ce。
错误:无须任何处理

可以直接执行增加镜像包

yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

四、执行yum install docker-ce
现在执行 如下命令来进行docker的安装

yum install docker-ce
但不幸的是。。。
安装中可能会遇到这个问题
https://download.docker.com/linux/cent/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found

细心的同学应该都发现了错误信息里提示了处理的方法
yum-config-manager --save --setopt=download.docker.com_linux_cent.skip_if_unavailable=true

当执行完成后

当执行完上面的这些操作,再执行
sudo yum install docker-ce
也许会成功,但也可能会继续遇到下面的问题。。。

五、异常Cannot download repodata/repomd.xml
1、安装yum install docker-ce 提示异常

[root@localhost ~]# yum install docker-ce
Docker CE Stable - aarch64 128 kB/s | 48 kB 00:00
created by dnf config-manager from https://download.docker.com/linux/cent 247 B/s | 365 B 00:01
Errors during downloading metadata for repository 'download.docker.com_linux_cent':
- Status code: 404 for https://download.docker.com/linux/cent/repodata/repomd.xml (IP: 13.224.250.127)
错误:Failed to download metadata for repo 'download.docker.com_linux_cent': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried


这里发现download 一直提示404,于是cd 到该/etc/yum.repos.d/目录下去看看究竟是怎么回事

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
docker-ce.repo download.docker.com_linux_cent.repo openEuler.repo
[download.docker.com_linux_cent]
name=created by dnf config-manager from https://download.docker.com/linux/cent
baseurl=https://download.docker.com/linux/cent
enabled=1
~
~
2、在浏览器输入对应地址https://download.docker.com/linux/centos/发现这个才是对的


3、于是果断将 https://download.docker.com/linux/cent改成https://download.docker.com/linux/centos/7/source/stable/

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
docker-ce.repo download.docker.com_linux_cent.repo openEuler.repo
[download.docker.com_linux_cent]
#name=created by dnf config-manager from https://download.docker.com/linux/cent
name=created by dnf config-manager from https://download.docker.com/linux/centos/7/source/stable/
#baseurl=https://download.docker.com/linux/cent
baseurl=https://download.docker.com/linux/centos/7/source/stable/
enabled=1

4、再把里面的$releasever全部改成7

vi /etc/yum.repos.d/CentOS-Base.repo
#命令行情况下输入,将文件中$releasever全部改成7
:%s/$releasever/7/g
5、最后执行yum install docker安装成功

【注意】不要使用yum install docker-ce 安装会提示如下错误


六、Error: Failed to download metadata for repo ‘download.docker.com_linux_cent’: Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
又是一篇错误

Failed to set locale, defaulting to C.UTF-8
created by dnf config-manager from https://download.docker.com/linux/cent 186 B/s | 365 B 00:01
Errors during downloading metadata for repository 'download.docker.com_linux_cent':
- Status code: 404 for https://download.docker.com/linux/cent/repodata/repomd.xml (IP: 54.230.21.60)
Error: Failed to download metadata for repo 'download.docker.com_linux_cent': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
Ignoring repositories: download.docker.com_linux_cent
Last metadata expiration check: 0:05:07 ago on Wed Apr 27 20:55:33 2022.
Error:
Problem: package docker-ce-3:20.10.14-3.el8.x86_64 requires containerd.io >= 1.4.1, but none of the providers can be installed
- package containerd.io-1.4.10-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64
- package containerd.io-1.4.10-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64
- package containerd.io-1.4.11-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64
- package containerd.io-1.4.11-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64
- package containerd.io-1.4.12-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64
- package containerd.io-1.4.12-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64
- package containerd.io-1.4.13-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64
- package containerd.io-1.4.13-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64
- package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64
- package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64
- package containerd.io-1.4.3-3.2.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64
- package containerd.io-1.4.3-3.2.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64
- package containerd.io-1.4.4-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64
- package containerd.io-1.4.4-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64
- package containerd.io-1.4.6-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64
- package containerd.io-1.4.6-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64
- package containerd.io-1.4.8-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64
- package containerd.io-1.4.8-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64
- package containerd.io-1.4.9-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64
- package containerd.io-1.4.9-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64
- package containerd.io-1.5.10-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64
- package containerd.io-1.5.10-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64
- package containerd.io-1.5.11-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64
- package containerd.io-1.5.11-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64
- problem with installed package buildah-1.22.3-2.module_el8.5.0+911+f19012f9.x86_64
- package buildah-1.22.3-2.module_el8.5.0+911+f19012f9.x86_64 requires runc >= 1.0.0-26, but none of the providers can be installed
- cannot install the best candidate for the job
- package runc-1.0.0-56.rc5.dev.git2abd837.module_el8.3.0+569+1bada2e4.x86_64 is filtered out by modular filtering
- package runc-1.0.0-66.rc10.module_el8.5.0+1004+c00a74f5.x86_64 is filtered out by modular filtering
- package runc-1.0.0-72.rc92.module_el8.5.0+1006+8d0e68a2.x86_64 is filtered out by modular filtering
(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)


于是修改了下载的配置

[root@localhost speedtest-cli]# vim /etc/yum.repos.d/docker-ce.repo
1


七、错误:软件包:containerd.io-1.5.11-3.1.el7.x86_64 (docker-ce-stable) 需要:container-selinux >= 2:2.74
也许还会遇到如下问题

[root@localhost ~]# yum install docker-ce
已加载插件:fastestmirror, product-id, search-disabled-repos
docker-ce-stable | 3.5 kB 00:00:00
(1/2): docker-ce-stable/updateinfo | 55 B 00:00:00
(2/2): docker-ce-stable/primary_db | 75 kB 00:00:00
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 docker-ce.x86_64.3.20.10.14-3.el7 将被 安装
--> 解决依赖关系完成
错误:软件包:containerd.io-1.5.11-3.1.el7.x86_64 (docker-ce-stable)
需要:container-selinux >= 2:2.74
错误:软件包:docker-ce-rootless-extras-20.10.14-3.el7.x86_64 (docker-ce-stable)
需要:fuse-overlayfs >= 0.7
错误:软件包:docker-ce-rootless-extras-20.10.14-3.el7.x86_64 (docker-ce-stable)
需要:slirp4netns >= 0.4
错误:软件包:3:docker-ce-20.10.14-3.el7.x86_64 (docker-ce-stable)
需要:container-selinux >= 2:2.74
您可以尝试添加 --skip-broken 选项来解决该问题
** 发现 1 个已存在的 RPM 数据库问题, 'yum check' 输出如下:
rhn-check-2.0.2-24.el7.x86_64 有缺少的需求 yum-rhn-plugin >= ('0', '1.6.4', '1')
[root@localhost ~]# yum install container-selinux
已加载插件:fastestmirror, product-id, search-disabled-repos
Loading mirror speeds from cached hostfile
没有可用软件包 container-selinux。
错误:无须任何处理


执行缺失依赖安装

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
1
vi /etc/yum.repos.d/CentOS-Base.repo
#命令行情况下输入,将文件中$releasever全部改成7
:%s/$releasever/7/g
然后clean

yum clean all
再建立缓存

yum makecache
最后再执行

yum install docker-ce
如果没有异常,恭喜到此成功不许要看下面的异常处理了。

八、安装符合自己系统的containerd.io
修改完了再执行sudo yum install docker-ce

现在提示的错误到时少了一大截

Failed to set locale, defaulting to C.UTF-8
Docker CE Stable - x86_64 136 kB/s | 40 kB 00:00
created by dnf config-manager from https://download.docker.com/linux/cent 229 B/s | 365 B 00:01
Errors during downloading metadata for repository 'download.docker.com_linux_cent':
- Status code: 404 for https://download.docker.com/linux/cent/repodata/repomd.xml (IP: 54.230.21.56)
Error: Failed to download metadata for repo 'download.docker.com_linux_cent': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
Ignoring repositories: download.docker.com_linux_cent
Error:
Problem: package docker-ce-3:20.10.14-3.el7.x86_64 requires containerd.io >= 1.4.1, but none of the providers can be installed
- cannot install the best candidate for the job
- package containerd.io-1.4.10-3.1.el7.x86_64 is filtered out by modular filtering
- package containerd.io-1.4.11-3.1.el7.x86_64 is filtered out by modular filtering
- package containerd.io-1.4.12-3.1.el7.x86_64 is filtered out by modular filtering
- package containerd.io-1.4.13-3.1.el7.x86_64 is filtered out by modular filtering
- package containerd.io-1.4.3-3.1.el7.x86_64 is filtered out by modular filtering
- package containerd.io-1.4.3-3.2.el7.x86_64 is filtered out by modular filtering
- package containerd.io-1.4.4-3.1.el7.x86_64 is filtered out by modular filtering
- package containerd.io-1.4.6-3.1.el7.x86_64 is filtered out by modular filtering
- package containerd.io-1.4.8-3.1.el7.x86_64 is filtered out by modular filtering
- package containerd.io-1.4.9-3.1.el7.x86_64 is filtered out by modular filtering
- package containerd.io-1.5.10-3.1.el7.x86_64 is filtered out by modular filtering
- package containerd.io-1.5.11-3.1.el7.x86_64 is filtered out by modular filtering
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
[root@localhost speedtest-cli]# yum-config-manager --save --setopt=download.docker.com_linux_cent.skip_if_unavailable=true
Failed to set locale, defaulting to C.UTF-8


但是还是有,于是去盲目安装containerd.io,如CentOS 上 安装Docker (解决安装过程中遇到的问题)

当初我根据资料直接拷贝进行containerd.io的安装(选了一个最新版本),最后安装完了不是自己系统所缺失的;于是白安装了,问题依然在。

最后兜兜转转才发现,不是每一个人都适合自己,没有最好的只有最适合的。于是终于明白我们得根据自己系统版本来安装对应的版本!

1、查看自己系统的版本

[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 8.5.2111
2、根据自己的系统版本

去官网https://download.docker.com/linux/centos/ 找到自己对应的版本

我是8.5

按照/x86_64/edge/Packages/这个目录一直点进去


发现了一个我一直缺少的io

安装所需 io

[root@localhost speedtest-cli]# yum install https://download.docker.com/linux/centos/8/x86_64/edge/Packages/containerd.io-1.3.7-3.1.el8.x86_64.rpm

这里安装发现与原来安装过的1.2冲突了

Error:
Problem: problem with installed package containers-common-2:1-2.module_el8.5.0+890+6b136101.noarch
- package containers-common-2:1-2.module_el8.5.0+890+6b136101.noarch requires runc, but none of the providers can be installed
- package containerd.io-1.2.13-3.2.el7.x86_64 conflicts with containerd provided by containerd.io-1.3.7-3.1.el8.x86_6
那就先卸载再说

root@localhost speedtest-cli]# yum remove docker-ce docker-ce-cli containerd.io

然后再执行

yum install https://download.docker.com/linux/centos/8/x86_64/edge/Packages/containerd.io-1.3.7-3.1.el8.x86_64.rpm
1
九、再执行yum install docker-ce
[root@localhost speedtest-cli]# yum install docker-ce
Failed to set locale, defaulting to C.UTF-8
created by dnf config-manager from https://download.docker.com/linux/cent 94 B/s | 365 B 00:03
Errors during downloading metadata for repository 'download.docker.com_linux_cent':
- Status code: 404 for https://download.docker.com/linux/cent/repodata/repomd.xml (IP: 54.230.21.10)
Error: Failed to download metadata for repo 'download.docker.com_linux_cent': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
Ignoring repositories: download.docker.com_linux_cent
Last metadata expiration check: 0:42:32 ago on Wed Apr 27 21:47:38 2022.
Dependencies resolved.
========================================================================================================================================================================================
Package Architecture Version Repository Size
========================================================================================================================================================================================
Installing:
docker-ce x86_64 3:20.10.14-3.el8 docker-ce-stable 22 M
Upgrading:
containerd.io x86_64 1.5.11-3.1.el8 docker-ce-stable 29 M
Installing dependencies:
docker-ce-cli x86_64 1:20.10.14-3.el8 docker-ce-stable 30 M
docker-ce-rootless-extras x86_64 20.10.14-3.el8 docker-ce-stable 4.6 M
docker-scan-plugin x86_64 0.17.0-3.el8 docker-ce-stable 3.8 M
fuse-overlayfs x86_64 1.7.1-1.module_el8.5.0+890+6b136101 appstream 73 k
fuse3 x86_64 3.2.1-12.el8 baseos 50 k
fuse3-libs x86_64 3.2.1-12.el8 baseos 94 k
libcgroup x86_64 0.41-19.el8 baseos 70 k
libslirp x86_64 4.4.0-1.module_el8.5.0+890+6b136101 appstream 70 k
slirp4netns x86_64 1.1.8-1.module_el8.5.0+890+6b136101 appstream 51 k

Transaction Summary
========================================================================================================================================================================================
Install 10 Packages
Upgrade 1 Package

Total download size: 90 M
Is this ok [y/N]: y

哈哈哈看这下终于成功了

十、验证安装
执行命令

1、sudo docker version 或者 docker –v(查看docker 版本信息)

[root@iZbp15rmf8lyj2yhq136ebZ ~]# sudo docker version
Client: Docker Engine - Community
Version: 19.03.5
API version: 1.40
Go version: go1.12.12
Git commit: 633a0ea
Built: Wed Nov 13 07:25:41 2019
OS/Arch: linux/amd64
Experimental: false
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

2、docker 版本简要信息
执行命令 docker -v

[root@iZbp15rmf8lyj2yhq136ebZ ~]# docker -v
Docker version 19.03.5, build 633a0ea

2、docker --help (帮助)
[root@iZbp15rmf8lyj2yhq136ebZ ~]# docker --help

Usage: docker [OPTIONS] COMMAND

A self-sufficient runtime for containers

Options:
--config string Location of client config files (default "/root/.docker")
-c, --context string Name of the context to use to connect to the daemon (overrides
DOCKER_HOST env var and default context set with "docker context use")
-D, --debug Enable debug mode
-H, --host list Daemon socket(s) to connect to
-l, --log-level string Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default


wait Block until one or more containers stop, then print their exit codes

Run 'docker COMMAND --help' for more information on a command.


3、查看某个命令具体配置

[root@iZbp15rmf8lyj2yhq136ebZ ~]# docker rmi --help

Usage: docker rmi [OPTIONS] IMAGE [IMAGE...]

Remove one or more images

Options:
-f, --force Force removal of the image
--no-prune Do not delete untagged parents

4、docker详细信息查看
执行命令docker info
[root@iZbp15rmf8lyj2yhq136ebZ ~]# docker info
Client:
Debug Mode: false

Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 19.03.5
Storage Driver: overlay2
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false

 

十一、启动docker
执行命令sudo systemctl start docker


[root@iZbp15rmf8lyj2yhq136ebZ ~]# sudo systemctl start docker

## 或者 执行
[root@iZbp15rmf8lyj2yhq136ebZ ~]# sudo service docker start
#启动docker
[root@iZbp15rmf8lyj2yhq136ebZ ~]# service docker start
#加入开机启动
[root@iZbp15rmf8lyj2yhq136ebZ ~]# chkconfig docker on


ok 到这里安装docker 算是告一段落了,感谢阅读,有任何疑问欢迎评论留言互相交流学习;也欢迎点赞关注和转换,让技术改变生活让我们一起加油😀
————————————————
版权声明:本文为CSDN博主「奔跑的痕迹」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_34817440/article/details/103568615

posted @ 2024-01-17 16:45  韩梦芫  阅读(742)  评论(0编辑  收藏  举报