How to uninstall and install Docker under Linux (Centos 7) operating system


Preface

Since the Docker versions on my two Linux machines are inconsistent, I want to synchronize the two versions.

Uninstall Docker

Step 1 : Uninstall Docker through rpm command

rpm -qa|grep docker|xargs rpm -ev --allmatches --nodeps

Step 2 : Uninstall Docker-related files

 whereis docker |xargs rm -frv

Step 3 : Check if there are any uninstallation residues

whereis docker

Step 4 : Delete images and containers

rm -rf /var/lib/docker

Install Docker

Step 1 : Install the dependencies required by Docker

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

Step 2 : Check the downloadable versions of Docker

sudo yum list docker-ce --showduplicates | sort -r

insert image description here
Select the version you want to download. Here I chose version 18.09.2.
Step 3 : Use the following code to install Docker Client and Docker Engine at the same time.

sudo yum install docker-ce-18.09.2-3.el7 docker-ce-cli-18.09.2-3.el7 containerd.io

Display Complete! Indicates installation is complete
insert image description here

Step 4 : Use the docker version to check whether the installation is successful.
insert image description here
It is found that the Docker Server is not displayed normally. The initial suspicion is that the Docker service has not started.

Step 5 : Start Docker

# 查看docker状态
sudo systemctl status docker
# 启动docker状态
sudo systemctl start docker
# 设置docker自启动
sudo systemctl enable docker

Step 6 : Check Docker again
insert image description here
and find that it can be displayed normally. At this point the Docker installation is complete.

Guess you like

Origin blog.csdn.net/biyn9/article/details/131191446