centos 安装docker
官方参考地址:https://docs.docker.com/install/linux/docker-ce/centos/
里面包含包下载地址: https://download.docker.com/linux/centos/7/x86_64/stable/Packages/
一、安装依赖
yum install -y yum-utils device-mapper-persistent-data lvm2
二、增加docker管理源
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
三、安装docker
yum install docker-ce docker-ce-cli containerd.io
这时可能会报错,如果没报错则安装成功
Error:
Problem: package docker-ce-3:19.03.8-3.el7.x86_64 requires containerd.io >= 1.2.2-3, but none of the providers can be installed
- cannot install the best candidate for the job
- package containerd.io-1.2.10-3.2.el7.x86_64 is excluded
- package containerd.io-1.2.13-3.1.el7.x86_64 is excluded
- package containerd.io-1.2.2-3.3.el7.x86_64 is excluded
- package containerd.io-1.2.2-3.el7.x86_64 is excluded
- package containerd.io-1.2.4-3.1.el7.x86_64 is excluded
- package containerd.io-1.2.5-3.1.el7.x86_64 is excluded
- package containerd.io-1.2.6-3.3.el7.x86_64 is excluded
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
报错原因containerd.io >= 1.2.2-3 ,意思就是 containerd.io 的版本必须大于等于 1.2.2-3
需要对containerd.io 进行升级
dnf install https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm
升级完之后,再安装docker:
yum install docker-ce docker-ce-cli containerd.io
安装过程可能还会报错,我报错的内容是与 podman-manpages 软件冲突
报错部分代码为:
Total 82 kB/s | 64 MB 13:18
Running transaction check
Transaction check succeeded.
Running transaction test
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'dnf clean packages'.
Error: Transaction check error:
file /usr/share/man/man1/docker-attach.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
file /usr/share/man/man1/docker-build.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
file /usr/share/man/man1/docker-commit.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
file /usr/share/man/man1/docker-container-prune.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
file /usr/share/man/man1/docker-container.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
file /usr/share/man/man1/docker-cp.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
file /usr/share/man/man1/docker-create.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
....
这时我们需要卸载掉 podman-manpages 就可以了
卸载podman-manpages
yum remove podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
这时再安装docker就成功了:
yum install docker-ce docker-ce-cli containerd.io
查看安装docker版本:
[root@localhost ~]# docker -v
Docker version 19.03.8, build afacb8b
启动Docker
systemctl start docker
设置Docker开机自启:
systemctl enable docker