How to Completely Uninstall Docker from Ubuntu
You completely uninstall Docker from Ubuntu by removing the Docker Engine, CLI, and associated packages, then cleaning up remaining data like images, containers, and volumes.
Docker is a platform that allows you to build, ship, and run applications within isolated environments called containers. These containers package your application and its dependencies, ensuring consistency across different systems.
Simply removing Docker packages often leaves behind essential data such as your existing Docker images, containers, and configuration files. For a complete removal on Ubuntu, you must target these leftover elements after uninstalling the core software.
This process is vital when freeing up disk space, resolving software conflicts, or preparing for a fresh Docker installation. A thorough uninstallation guarantees your Ubuntu system is entirely free of all Docker-related components.
Completely uninstall Docker by first removing all containers, images, networks, and volumes using docker commands. Then, remove the Docker packages with sudo apt remove docker-* –auto-remove and clean up residual directories like /var/lib/docker.
Delete Docker images, containers, and volumes
As mentioned above, users can delete Docker images, containers, volumes, and other configuration files before uninstalling Docker.
Here’s how to do that.
First, stop the Docker containers that are running, then remove them.
Run the command below to do that.
docker stop $(docker ps -a -q)
The command will list all the Docker containers and stop them. Once they are stopped, run the command below to remove them.
docker rm $(docker ps -a -q)
Next, remove Docker images. Run the command below to do that. The command lists all the active and intermediate images and removes them from the system.
docker rmi $(docker images -a -q)
Next, remove all Docker networks. The command will remove Docker custom networks from the system.
docker network prune
Next, remove all cache and volumes. You can do that using the command below.
docker system prune -a
The command will perform the following actions:
- Remove all stopped containers
- Remove networks that are not used by at least one container
- Remove Images without at least one container associated with them
- Remove build cache
Confirm when prompted.
Finally, uninstall Docker packages and delete leftover files. You can do that by running the commands below.
sudo apt remove docker-* --auto-remove sudo rm -rf /var/lib/docker sudo groupdel docker sudo rm -rf /var/run/docker.sock sudo rm -rf /usr/local/bin/docker-compose && sudo rm -rf /etc/docker && sudo rm -rf ~/.docker
That should do it!
Conclusion:
- The guide provided comprehensive instructions on how to uninstall Docker from Ubuntu Linux, covering the deletion of images, containers, volumes, and packages and removing leftover files and configurations.
- Following these steps will effectively free up space on the system and ensure the complete removal of Docker and its associated components.
- Users are encouraged to share feedback or additional insights through the comments section for future reference and improvement.
Was this guide helpful?
About the Author
Richard
Tech Writer, IT Professional
Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.
No comments yet — be the first to share your thoughts!