SoFunction
Updated on 2025-03-09

Detailed tutorial on two methods of complete uninstallation of Docker

Introduction

Docker is a lightweight containerized platform that helps developers package applications and their dependencies into a portable container. But sometimes we may need to completely uninstall Docker, uninstall the old version and install the new version, or no longer need the Docker environment.

Method 1

1. Stop Docker service

First stop the running Docker service. Execute the following command:

sudo systemctl stop docker

2. Delete the Docker installation package

Next, delete the installed Docker package. Execute the following command:

sudo apt-get purge docker-ce docker-ce-cli 

3. Delete Docker-related files

Deleting Docker-related files ensures that Docker is completely uninstalled. Execute the following command:

sudo rm -rf /var/lib/docker
sudo rm -rf /etc/docker
sudo rm -rf /var/run/

4. Delete Docker user group

Finally, we need to delete the Docker user group. Execute the following command:

sudo groupdel docker

Method 2

1. Check if there are any old versions installed

# Applicable to systems that use yum to install dockeryum list installed | grep docker

# Or check the docker versiondocker --version

If nothing appears, it means that docker has not been installed, or if the command does not exist, it means that docker has not been installed.

2. Stop docker

systemctl stop docker

Check whether the docker status has stopped

systemctl status docker

3. Delete related packages that have installed docker

Delete all, the command is as follows:

yum -y remove .x86_64 \ 
              docker-buildx-plugin.x86_64 \ 
              docker-ce.x86_64 \ 
              docker-ce-cli.x86_64 \ 
              docker-ce-rootless-extras.x86_64 \ 
              docker-compose-plugin.x86_64

Delete the relevant packages:

yum remove -y docker*

Attachment: Precautions

Use these commands carefully to make sure you do not delete important data that has not been backed up.

These commands will delete locally stored data. If you want to keep data, make sure to back up these commands before executing them.

Before executing these commands, make sure you have stopped the running container.

Please selectively use these commands according to your specific circumstances and needs.

Summarize

The first method tends to use the Ubuntu system, and the second method tends to use the CentOS system, but basically all of them can complete the deletion of docker. Docker can be completely deleted from the system through the above two methods!

This is the end of this article about the two methods of complete Docker uninstallation. For more related content on complete Docker uninstallation, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!