Older versions of Docker were called docker or docker-engine. If these are installed, uninstall them, along with associated dependencies.
sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
Before you install Docker Engine for the first time on a new host machine, you need to set up the Docker repository. Afterward, you can install and update Docker from the repository.
Install the yum-utils
package (which provides the yum-config-manager
utility) and set up the stable repository.
sudo yum install -y yum-utils

#使用官方镜像
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
#使用阿里云加速
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Install the latest version of Docker Engine and containerd, or go to the next step to install a specific version:
sudo yum install docker-ce docker-ce-cli containerd.io
Start Docker.
sudo systemctl status docker
sudo systemctl enable docker
sudo systemctl start docker
Uninstall the Docker Engine, CLI, and Containerd packages:
sudo yum remove docker-ce docker-ce-cli containerd.io
Images, containers, volumes, or customized configuration files on your host are not automatically removed. To delete all images, containers, and volumes:
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd
原文:https://www.cnblogs.com/shizuwei/p/14516107.html