TroubleChute Logo
DOCKER

Completely uninstall Docker (I mean everything)


Published: Nov 12, 2022
Last Edit: Nov 12, 2022
Docker
327 Words, 1 Minute.

Why?

Well, say you were messing around with settings, and things went REALLY wrong. Like a simple uninstall and reinstall didn’t work - Or you are done testing things out and want it ALL gone.

This goes MUCH deeper than a simple apt uninstall. This could be considered the nuclear option, but it works.

The commands

Check which docker packages are installed.

1
dpkg -l | grep -i docker

Then remove them all. You may need to add to this list (using names from the first command). On a relatively clean install: it’ll probably cover everything.

1
2
sudo apt-get purge -y docker-engine docker docker.io docker-ce docker-ce-cli docker-compose-plugin
sudo apt-get autoremove -y --purge docker-engine docker docker.io docker-ce docker-compose-plugin

Or, if you installed with snap:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Delete Docker
sudo snap remove --purge docker

# Find leftover packages
sudo find / -name "*docker*"

# Then delete them using the command above.
# DO NOT USE THIS LAST COMMAND UNLESS YOU UNDERSTAND WHAT IT DOES!
sudo find / -name "*docker*"
# If this returns ONLY packages you want gone, add the following to the end of the last command (Without the #):
#  -exec `rm -rf` {} +

To delete images, containers, volumes, and other user-created config files on the host, run:

1
2
3
4
5
6
sudo umount /var/lib/docker/
sudo rm -rf /var/lib/docker /etc/docker
sudo rm /etc/apparmor.d/docker
sudo groupdel docker
sudo rm -rf /var/run/docker.sock
sudo rm -rf /usr/bin/docker-compose

Then for some leftover files:

1
2
3
4
sudo rm -rf /usr/local/bin/docker-compose
sudo rm -rf /etc/docker
sudo apt-get purge docker-ce-cli
sudo rm -rf ~/.docker

Stubborn files

To find other (possible) leftover files, use the find command and delete them manually:

1
sudo find / -name '*docker*'

RESTART!

Restart your server to get rid of anything else that could be leftover and running.

1
reboot

These commands were based on a few responses and comments on the askubuntu forum

TCNO TechNobo / TroubleChute © Wesley Pyburn (TechNobo / TroubleChute)