How to Uninstall Docker on Ubuntu

How to Uninstall Docker on Ubuntu

Docker has revolutionized the way applications are developed, shipped, and deployed. However, there might be instances where you need to uninstall Docker from your system, perhaps to reinstall it or to free up resources.

In this guide, we’ll walk you through the steps to completely remove Docker from an Ubuntu system.

Let’s get started.

Step 1: Stop All Running Docker Containers

Before uninstalling Docker, ensure that all Docker containers are stopped.

sudo docker stop $(sudo docker ps -aq)

This command stops all running Docker containers by listing all containers with docker ps -aq and then stopping them with docker stop.

Step 2: Remove Docker Packages

Next, uninstall Docker packages using the package manager.

sudo apt-get purge docker-ce docker-ce-cli

This command will remove Docker but retain the configuration files and images.

See also  How to Restart PostgreSQL in Ubuntu

Step 3: Remove Docker Configuration and Image Files

If you want to remove all Docker configurations, images, and volumes, you can delete the Docker directory.

sudo rm -rf /var/lib/docker

Be cautious with this step, as it will delete all your Docker images, containers, volumes, and configurations.

Step 4: Remove Docker Dependencies

Docker might have installed dependencies that are no longer used. You can remove them with:

sudo apt-get autoremove

Step 5: Remove Docker GPG Key

Docker’s GPG key was added during the Docker installation to ensure the integrity of the downloaded packages. To remove it:

sudo apt-key del $(sudo apt-key list | grep Docker | awk '{print $2}')

Commands Mentioned

  • sudo docker stop $(sudo docker ps -aq) – Stops all running Docker containers.
  • sudo apt-get purge docker-ce docker-ce-cli – Removes Docker packages.
  • sudo rm -rf /var/lib/docker – Deletes Docker configurations, images, and volumes.
  • sudo apt-get autoremove – Removes unused dependencies.
  • sudo apt-key del $(sudo apt-key list | grep Docker | awk ‘{print $2}’) – Removes Docker’s GPG key.
See also  How to Uninstall October CMS on Ubuntu


  1. Why might I need to uninstall Docker?

    There could be several reasons, such as needing to reinstall Docker, resolving conflicts, freeing up system resources, or transitioning to a different containerization tool.

  2. Is it safe to delete the /var/lib/docker directory?

    Yes, but it will remove all Docker images, containers, volumes, and configurations. Ensure you have backups of necessary data before proceeding.

  3. Can I reinstall Docker after uninstalling?

    Absolutely! Uninstalling Docker doesn’t prevent you from reinstalling it in the future.

  4. Will uninstalling Docker affect other software on my system?

    No, uninstalling Docker should not affect other software. However, any applications running inside Docker containers will be affected.

  5. How can I verify that Docker has been completely removed?

    You can check by trying to run Docker commands or checking for its service. If they don’t respond or show errors, Docker has likely been removed.

See also  How to Install jnetmap on Ubuntu


Uninstalling Docker from Ubuntu is a straightforward process, but it’s essential to follow the steps carefully to ensure a complete removal.

Whether you’re transitioning to a different containerization tool or merely freeing up system resources, this guide has provided you with the necessary steps to uninstall Docker safely.

If you’re exploring different hosting solutions, don’t forget to check out our guides on dedicated server hosting, VPS hosting, cloud hosting, and shared hosting.


Leave a Reply

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