Skip to content
Follow
Ubuntu Linux

How to Completely Uninstall Docker from Ubuntu

Richard
Written by
Richard
Oct 7, 2023 Updated Aug 13, 2026 2 min read
How to Change Default Apps in Ubuntu
How to Change Default Apps in Ubuntu

Removing Docker from Ubuntu requires deleting the main program along with all leftover containers, images, and stored data. Docker is a software tool that runs applications inside isolated boxes called containers so they do not mess up the rest of your system.

Standard package removal usually leaves hidden files and large data folders lingering on your hard drive. A full cleanup reclaims valuable disk space and clears out stubborn software problems before you try a fresh installation.

⚡ Quick Answer

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

Before uninstalling Docker, clear out unnecessary images, containers, and volumes. Running `docker stop $(docker ps -a -q)` halts active containers so removal proceeds without errors.

Here is how to tackle the cleanup.

Halt all active containers first by running this command:

Run the command below to do that.

💻Code
docker stop $(docker ps -a -q)

This command lists all Docker containers and stops them. Once they halt, run the command below to remove them entirely.

💻Code
docker rm $(docker ps -a -q)

Next, remove Docker images. Run the command below to do that. This command lists all active and intermediate images and removes them from your system.

💻Code
docker rmi $(docker images -a -q)

Next, remove all Docker networks. This command will remove Docker custom networks from the system.

💻Code
docker network prune

Next, clear out the remaining cache and volumes with this prune command:

💻Code
docker system prune -a

This single command sweeps away stopped containers, unused networks, unassociated images, and the build cache.

  • 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

Press y and hit Enter when the confirmation prompt appears.

To fully uninstall Docker packages and delete leftover files, you can run the following commands. This process ensures no residual Docker data remains on your Ubuntu system after the removal.

🐧Bash / Shell
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?

Was this helpful?
Richard

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.

📚 Related Tutorials

How to Install Docker Ubuntu: Terminal Commands
Ubuntu Linux How to Install Docker Ubuntu: Terminal Commands
How to Uninstall Software in Ubuntu Linux
Ubuntu Linux How to Uninstall Software in Ubuntu Linux
How to Install JasperReports Server on Ubuntu Linux
CMS How to Install JasperReports Server on Ubuntu Linux
How to Install Etherpad on Ubuntu Linux
Ubuntu Linux How to Install Etherpad on Ubuntu Linux

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *