install docker前期准备
一般安装docker-ce版本,如果已经安装过docker,需要提前卸载所有相关包,这里不做赘述
# 设置存储库的命令yum-config-manager,该命令是在yum-utils包下,所以要先安装yum-utils
`yum install -y yum-utils`
#设置稳定版docker的存储库,使用下面的存储库在下载docker的时候可能会比较慢,可以按需修改为国内的存储库。
# a.官方默认的存储库
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# b.或者设置为阿里的存储库
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
安装:
yum install docker-ce docker-ce-cli containerd.io -y
但是安装失败,系统提示:
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 --allowerasing docker-ce docker-ce-cli containerd.io -y
安装docker-ce相关包的log如下:
Installing:
containerd.io x86_64 1.6.28-3.1.el8 docker-ce-stable 35 M
replacing runc.x86_64 1:1.1.3-3.module+el8.6.0+20860+bf01bdf2
docker-ce x86_64 3:25.0.3-1.el8 docker-ce-stable 26 M
docker-ce-cli x86_64 1:25.0.3-1.el8 docker-ce-stable 7.3 M
Installing dependencies:
crun x86_64 1.8.7-1.module+el8.9.0+90147+a4870853
OL8-appstream-x86_64 238 k
libcgroup x86_64 0.41-19.el8 OL8-baseos-x86_64 70 k
yajl x86_64 2.1.0-12.el8 OL8-appstream-x86_64 41 k
Installing weak dependencies:
criu-libs x86_64 3.15-3.module+el8.6.0+20857+bf01bdf2
OL8-appstream-x86_64 38 k
docker-buildx-plugin x86_64 0.12.1-1.el8 docker-ce-stable 13 M
docker-ce-rootless-extras x86_64 25.0.3-1.el8 docker-ce-stable 5.0 M
docker-compose-plugin x86_64 2.24.5-1.el8 docker-ce-stable 13 M
Removing dependent packages:
buildah x86_64 1:1.26.2-1.module+el8.6.0+20857+bf01bdf2
@OL8-appstream-x86_64 29 M
Downgrading:
containers-common x86_64 1:1.2.2-10.0.1.module+el8.4.0+20195+0a4a4953
OL8-appstream-x86_64 100 k
Transaction Summary
===============================================================================
Install 10 Packages
Remove 1 Package
Downgrade 1 Package
启动docker
systemctl start docker
设置开机自启动docker
systemctl enable docker
如果在启用或者自启动docker遇到如下报错,可以查看docker是否安装成功,可能需要重新安装docker:
Failed to start docker.service: Unit docker.service not found.