Removing Docker cleanly takes more than apt remove. Packages, images, containers, volumes, the apt repository and the docker group can all stay behind. This guide removes everything on Ubuntu 20.04, 22.04 and 24.04.
Warning: the steps in section 4 permanently delete all images, containers and volumes. If any volume holds data you need, such as a database, back it up first.
1. See what is installed and running
dpkg -l | grep -i docker docker ps -a docker images docker volume ls
The first command lists the Docker packages on the machine. The others show what you would lose in step 4.
2. Stop the services
sudo systemctl stop docker docker.socket containerd sudo systemctl disable docker docker.socket containerd
3. Remove the packages
sudo apt-get purge -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras docker.io sudo apt-get autoremove -y --purge
Packages that are not installed are simply reported by apt, so you can run the whole line safely. purge also deletes the packages' configuration files. If Docker came from Snap instead, run sudo snap remove docker.
4. Delete images, containers and volumes
sudo rm -rf /var/lib/docker /var/lib/containerd sudo rm -rf /etc/docker ~/.docker
5. Remove the apt repository and key
If you installed Docker from its official repository, remove it so apt update stops contacting it:
sudo rm -f /etc/apt/sources.list.d/docker.list /etc/apt/keyrings/docker.asc /etc/apt/keyrings/docker.gpg sudo apt-get update
6. Remove the docker group
sudo groupdel docker
Log out and back in so your session no longer carries the group.
7. Check that it is gone
which docker docker --version
Both should report that the command is not found. If a leftover binary shows up in /usr/local/bin, delete it by hand.
Reinstalling later
Because you removed the data directory, a new installation starts empty. Follow Docker's official Ubuntu instructions to install it again.
Covering financial markets, commodity rates, and practical technology insights for India. Researched and fact-checked in accordance with our Editorial Policy.
Related & Trending Stories
Recommended based on your reading interest

