Uninstalling Docker from your Ubuntu system is a straightforward process. Follow these friendly steps to ensure a clean removal:
Step 1: Stop Docker
Before uninstalling Docker, make sure it’s not running. You have to stop the Docker daemon with the following command:
sudo systemctl stop docker
Step 2: Remove Docker Packages
Now it’s time to remove the Docker packages. To remove Docker packages, use the following command. This will uninstall Docker while preserving configuration files:
sudo apt-get purge docker-ce docker-ce-cli containerd.io
Step 3: Remove Docker Images, Containers, and Volumes
Docker stores images, containers, and volumes in /var/lib/docker
. Remove these files and directories with caution:
sudo rm -rf /var/lib/docker
Step 4: Remove Docker Compose (if installed)
If Docker Compose is installed, remove it with:
sudo rm /usr/local/bin/docker-compose
Step 5: Remove Docker Group (optional)
If you created a Docker group, remove it with:
sudo groupdel docker
Step 6: Remove Docker Configuration Files (optional)
Remove the Docker configuration directory, if it exists:
sudo rm -rf /etc/docker
Step 7: Remove Docker User (optional)
If you created a Docker user, remove it with:
sudo deluser docker
Step 8: Update GRUB (optional)
If you want to remove Docker from the GRUB boot menu, update GRUB:
sudo update-grub
Step 9: Restart Your System
To apply all changes, restart your system:
sudo reboot
After completing these steps, Docker should be completely uninstalled from your Ubuntu system. Confirm the uninstallation by checking if docker --version
and docker-compose --version
no longer return recognized commands.
Congratulations! You’ve successfully uninstalled Docker from your Ubuntu system.