参考文档地址:https://docs.docker.com/engine/install/centos/
一、卸载旧版本docker及其依赖项
$ sudo yum remove docker\docker-client\docker-client-latest\docker-common\docker-latest\docker-latest-logrotate\docker-logrotate\docker-engine
二、设置存储库
$ sudo yum install -y yum-utils
$ sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
三、安装docker服务
$ sudo yum install -y docker-ce docker-ce-cli containerd.io
四、启用docker服务
$ sudo systemctl start docker
$ docker --version
五、设置服务自启
$ sudo systemctl enable docker
六、可能遇到问题
Problem: package docker-ce-3:20.10.0-3.el7.x86_64 requires containerd.io >= 1.4.1, but none of the providers can be installed
先安装containerd.io,版本不低于1.4.1
$ sudo yum install -y https://download.docker.com/linux/centos/8/x86_64/stable/Packages/containerd.io-1.4.3-3.1.el8.x86_64.rpm
Problem: problem with installed package podman-2.0.5-5.module_el8.3.0+512+b3b58dca.x86_64
卸载podman
$ sudo yum remove -y podman
Problem: problem with installed package buildah-1.15.1-2.module_el8.3.0+475+c50ce30b.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
可能一些依赖包冲突,需要覆盖安装。 原先命令后增加 --allowerasing