Uninstall old versions
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
Install using the repository
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.
SET UP 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
![](https://img2020.cnblogs.com/blog/2296296/202103/2296296-20210311100342041-1500321842.png)
#使用官方镜像
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 DOCKER ENGINE
-
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 Docker Engine
-
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