Skip to content
Follow
Ubuntu Linux

How to Completely Uninstall Docker from Ubuntu

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

Uninstalling Docker from Ubuntu deletes the main program along with any leftover containers, images, and stored data that standard package removal leaves behind. Docker is a software tool that runs applications inside isolated boxes called containers so they do not mess up the rest of your system.

Advertisement

Leftover files take up valuable disk space on your hard drive and cause stubborn software problems when you try a fresh installation. This guide shows you how to completely remove every trace of Docker and free up your system.

⚡ 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.

Advertisement

Delete Docker images, containers, and volumes

To completely uninstall Docker Ubuntu systems cleanly, you need to delete Docker images, containers, and volumes first so leftover files do not take up disk space. Run the stop command to halt active tasks, and then use the system prune command to wipe out all stored data, container files, and local volumes from your machine before you remove the software package itself.

Here is how to tackle the cleanup.

Halt all active containers first by running this command:

Run the command below to do that.

Advertisement
docker stop $(docker ps -a -q)

Stop all active containers and remove them entirely with this command:

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.

docker rmi $(docker images -a -q)

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

docker network prune

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

Advertisement
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.

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.

Advertisement

📚 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 *