安装依赖

yum install -y yum-utils device-mapper-persistent-data lvm2

添加yum源

yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

centos8默认使用podman代替docker
直接安装docker会出现以下错误

[root@localhost ~]# yum install docker-ce
上次元数据过期检查:0:00:13 前,执行于 20210613日 星期日 162232秒。
错误:
问题: package docker-ce-3:20.10.7-3.el8.x86_64 requires containerd.io >= 1.4.1, but none of the providers can be installed
  - package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-70.rc92.module_el8.4.0+673+eabfc99d.x86_64
  - package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-70.rc92.module_el8.4.0+673+eabfc99d.x86_64
  - package containerd.io-1.4.3-3.2.el8.x86_64 conflicts with runc provided by runc-1.0.0-70.rc92.module_el8.4.0+673+eabfc99d.x86_64
  - package containerd.io-1.4.3-3.2.el8.x86_64 obsoletes runc provided by runc-1.0.0-70.rc92.module_el8.4.0+673+eabfc99d.x86_64
  - package containerd.io-1.4.4-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-70.rc92.module_el8.4.0+673+eabfc99d.x86_64
  - package containerd.io-1.4.4-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-70.rc92.module_el8.4.0+673+eabfc99d.x86_64
  - package containerd.io-1.4.6-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-70.rc92.module_el8.4.0+673+eabfc99d.x86_64
  - package containerd.io-1.4.6-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-70.rc92.module_el8.4.0+673+eabfc99d.x86_64
  - problem with installed package buildah-1.19.7-1.module_el8.4.0+781+acf4c33b.x86_64
  - package buildah-1.19.7-1.module_el8.4.0+781+acf4c33b.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-64.rc10.module_el8.4.0+522+66908d0c.x86_64 is filtered out by modular filtering
  - package runc-1.0.0-65.rc10.module_el8.4.0+819+4afbd1d6.x86_64 is filtered out by modular filtering
  - package runc-1.0.0-70.rc92.module_el8.4.0+786+4668b267.x86_64 is filtered out by modular filtering
(尝试在命令行中添加 '--allowerasing' 来替换冲突的软件包 或 '--skip-broken' 来跳过无法安装的软件包 或 '--nobest' 来不只使用软件包的最佳候选)

解决办法,命令后追加 –allowerasing

yum install docker-ce docker-ce-cli containerd.io --allowerasing

或者先卸载podman

yum erase podman buildah

安装docker-ce

[root@localhost ~]# yum install docker-ce

安装:
 docker-ce                 x86_64 3:20.10.7-3.el8        docker-ce-stable  27 M
安装依赖关系:
 container-selinux         noarch 2:2.158.0-1.module_el8.4.0+781+acf4c33b
                                                         appstream         51 k
 containerd.io             x86_64 1.4.6-3.1.el8          docker-ce-stable  34 M
 docker-ce-cli             x86_64 1:20.10.7-3.el8        docker-ce-stable  33 M
 docker-ce-rootless-extras x86_64 20.10.7-3.el8          docker-ce-stable 9.2 M
 docker-scan-plugin        x86_64 0.8.0-3.el8            docker-ce-stable 4.2 M
 fuse-overlayfs            x86_64 1.4.0-2.module_el8.4.0+673+eabfc99d
                                                         appstream         72 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.3.1-1.module_el8.4.0+575+63b40ad7
                                                         appstream         69 k
 slirp4netns               x86_64 1.1.8-1.module_el8.4.0+641+6116a774
                                                         appstream         51 k

启动并设置开机自启动

systemctl start docker
systemctl enable docker

验证安装是否成功

docker version
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐