February 18, 2025

Tutorial on How to Completely Uninstall Docker (Engine) on Linux Ubuntu

In this tutorial, we explain how to completely uninstall Docker (Engine) on Linux Ubuntu and how to erase all the configuration files and folders (including hidden ones). The main motivation for completely removing Docker, images, and containers from a system comes from the fact that we often want to start with a fresh and clean installation of Docker. To do that, we first need to uninstall Docker and all configuration files. The YouTube tutorial is given below:

Uninstall Docker from Linux Ubuntu

To see all running and stopped Docker containers

docker ps -a

To see all images

docker images -a

To see the installation folder


docker info | grep "Docker Root Dir"

To erase all containers:


docker rm -vf $(docker ps -aq)

To erase all images

docker rmi -f $(docker images -aq)

Finally, to make sure that everything is deleted, that is to remove all unused containers, volumes, networks and images, type this:

docker system prune -a --volumes

First, we need to uninstall the Docker Engine, CLI, containerd, and Docker Compose packages and libraries:

sudo apt-get purge docker-ce docker-ce-cli
sudo apt-get purge containerd.io docker-buildx-plugin
sudo apt-get purge docker-compose-plugin docker-ce-rootless-extras

Next, we need to erase the folders storing containers, images, volumes, custom configuration files, etc:


 sudo rm -rf /var/lib/docker
 sudo rm -rf /var/lib/containerd

Next, we need to remove source list and keyrings

sudo rm /etc/apt/sources.list.d/docker.list
sudo rm /etc/apt/keyrings/docker.asc

Next, we need to install plocate such that we can search for other files and folders:

sudo apt install plocate
sudo updatedb

Search for docker:

plocate docker

You will see a a docker folder in /etc/ and a hidden folder in the home directory. Let us get rid of them:

sudo rm -rf /etc/docker
sudo rm -rf /home/ahaber/.docker

That is it!