How to Completely Remove Docker on Ubuntu (Engine & Desktop) – 2025 Tutorial
If you no longer need Docker, it’s a good idea to uninstall it properly to free up space and clean your system. In this guide, I will show you how to uninstall Docker on Ubuntu. The steps work on any version of Ubuntu, including Ubuntu Desktop and Ubuntu Server.
Step 1: Uninstall Docker Packages
What you need to do is run two simple commands:
for pkg in docker-ce docker-ce-cli docker-desktop docker-model-plugin containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get purge -y $pkg; done
sudo apt autoremove
- The first command uninstalls any Docker packages currently installed on your Ubuntu system – Docker Engine or Docker Desktop.
- The second command removes any unwanted dependencies left behind after the uninstall.
This ensures that Docker Engine or Docker Desktop packages are removed from your system.
After uninstalling, run this command to check if any Docker packages remain:
dpkg -l | grep -i docker
- If no results appear, Docker is completely removed.
- If you still see a Docker package, remove it manually using the
apt purge
command.
apt purge package_name
Step 2: Remove Docker Directories
The uninstall command does not remove local directories by default. To fully clean your system, you should delete them manually.
Here are some common Docker directories:
sudo rm -rf /var/lib/docker/
sudo rm -rf /var/lib/containerd/
rm -r $HOME/.docker/
sudo rm /usr/local/bin/com.docker.cli
Also, check and remove any Docker repository files located in /etc/apt/sources.list.d/
.
sudo rm /etc/apt/sources.list.d/docker.list
Reinstalling Docker on Ubuntu
If you want to install Docker again, you can follow our step-by-step guide on how to install the latest version of Docker on Ubuntu 24.
Conclusion
That’s how you uninstall Docker from Ubuntu. By removing packages, cleaning up directories, and deleting repositories, you ensure a complete uninstallation. This method works on all Ubuntu versions and is suitable for both servers and desktops.
