1. Preparation
1. Kill docker-related containers:
docker kill $(docker ps -a -q)
2. Delete all docker containers:
docker rm $(docker ps -a -q)
3. Delete all docker images:
docker rmi $(docker images -q)
4. Stop the docker service:
systemctl stop docker
5. Delete the docker-related storage directory: (Execute the following four commands respectively)
rm -rf /etc/docker
rm -rf /run/docker
rm -rf /var/lib/dockershim
rm -rf /var/lib/docker
6. If it cannot be deleted, umount first:
umount /var/lib/docker/devicemapper
7. Then re-execute the above step "Delete docker related storage directory".
2. Uninstallation work
After the above series of preparations, we finally reached the final stage and started to delete docker.
1. Check which docker packages have been installed on the system:
[root@localhost ~]# yum list installed | grep docker
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
containerd.io.x86_64 1.4.12-3.1.el7 @docker-ce-stable
docker-ce.x86_64 3:20.10.11-3.el7 @docker-ce-stable
docker-ce-cli.x86_64 1:20.10.11-3.el7 @docker-ce-stable
docker-ce-rootless-extras.x86_64 20.10.11-3.el7 @docker-ce-stable
docker-scan-plugin.x86_64 0.9.0-3.el7 @docker-ce-stable
Uninstall related packages:
[root@localhost ~]# yum remove containerd.io.x86_64 docker-ce.x86_64 docker-ce-cli.x86_64 docker-ce-rootless-extras.x86_64 docker-scan-plugin.x86_64
2. Then a selection prompt will appear, just enter "y" and press Enter.
3. Check again
yum list installed | grep docker
Relevant information no longer appears, proving that the deletion was successful.
4. Look at the docker command again:
[root@localhost ~]# docker version
-bash: /usr/bin/docker: 没有那个文件或目录