How to Completely Uninstall Docker

Uninstall Docker

Docker, the containerization platform, has revolutionized software development and deployment, offering a convenient and efficient way to package, distribute, and manage applications. However, there may come a time when you need to bid Docker farewell. Uninstalling Docker from your Linux system can be a complex process, but this comprehensive guide will walk you through it step by step. By the end, you’ll have a clean system ready for whatever comes next in your development journey.

Understanding Docker

Before we dive into the uninstallation process, let’s take a moment to understand what Docker is and why you might want to uninstall it. Docker allows you to package applications and their dependencies into containers, making it easy to deploy them consistently across different environments. While Docker is a powerful tool, you might want to uninstall it for various reasons, such as moving to an alternative containerization solution or simply reclaiming disk space.

Preparing for Uninstallation

Backup Considerations

Before you begin the uninstallation process, it’s crucial to back up any data you want to keep. While uninstalling Docker itself won’t delete your data, there’s always a risk of accidental data loss during the process.

  1. Backing up Containers and Images: If you have important containers or images, consider exporting them using the docker export or docker save commands.
  2. Exporting Docker Configurations: Docker configurations can be found in the /etc/docker/ directory. Make a copy of this directory for future reference.

System Requirements and Prerequisites

Ensure your system meets the following requirements and prerequisites:

  • Linux Distribution: Docker is typically installed on popular Linux distributions like Ubuntu, Debian, CentOS, and RHEL.
  • Root or Sudo Access: You’ll need root or sudo privileges to uninstall Docker.
  • Docker Containers: Ensure that all running Docker containers are stopped before proceeding.

Uninstalling Docker on Linux

Now, let’s get into the nitty-gritty of removing Docker from your Linux system.

A. Uninstall Docker using Package Manager


# Uninstall Docker
sudo apt-get remove docker-ce docker-ce-cli

# Purge configuration files
sudo apt-get purge docker-ce docker-ce-cli

# Delete images, containers, and volumes (Caution!)
sudo rm -rf /var/lib/docker


# Uninstall Docker
sudo yum remove docker-ce docker-ce-cli

# Delete images, containers, and volumes (Caution!)
sudo rm -rf /var/lib/docker

B. Manual Uninstallation

If you can’t remove Docker using your package manager or prefer a manual approach, follow these steps:

  1. Stopping Docker Services:
sudo systemctl stop docker
  1. Removing Docker Packages:
sudo yum list installed | grep docker   # CentOS/RHEL
sudo dpkg -l | grep docker              # Debian/Ubuntu

# Use the appropriate command to remove Docker packages
  1. Deleting Docker Directories and Files:
sudo rm -rf /etc/docker /var/lib/docker
  1. Cleaning up Docker-Related Dependencies:
sudo apt autoremove # Debian/Ubuntu
sudo yum autoremove # CentOS/RHEL

C. Removing Docker Compose

If you also have Docker Compose installed, remove it:

sudo rm /usr/local/bin/docker-compose

D. Disabling and Removing Docker-Related Services

Depending on your Linux distribution, you might need to disable and remove Docker-related services:

# Debian/Ubuntu
sudo systemctl disable docker
sudo systemctl disable containerd

sudo systemctl disable docker
sudo systemctl disable containerd

Verifying the Uninstallation

After uninstalling Docker, it’s essential to verify that there are no remaining Docker artifacts or processes on your system.

A. Checking for Remaining Docker Artifacts:

docker --version # Ensure Docker commands are not recognized

B. Ensuring Docker Processes Are Stopped:

ps aux | grep docker # Ensure no Docker-related processes are running

Reclaiming Disk Space

Uninstalling Docker is one thing, but regaining valuable disk space is another. Here’s how you can clean up your system:

A. Identifying and Deleting Unused Docker Images and Containers:

docker image prune -a
docker container prune

B. Cleaning up Docker Volumes and Networks:

docker volume prune
docker network prune

Post-Uninstallation Best Practices

With Docker uninstalled and your system cleaned up, consider these best practices:

A. Considerations for Alternative Containerization Solutions:

  • Explore alternatives like Podman, LXC, or Kubernetes if your containerization needs persist.

B. Documenting the Uninstallation Process for Future Reference:

  • Create a detailed guide or document outlining the steps you followed. This will be invaluable if you ever need to install Docker again or assist others with the process.

Troubleshooting Common Issues

Sometimes, things don’t go as planned. Here are some common issues you might encounter during the uninstallation process:

A. Handling Issues During Uninstallation:

  • If you encounter errors, check the error messages for clues on how to resolve them. Common issues include dependencies not being properly removed or services not stopping.

B. Dealing with Residual Docker Components:

  • If you still see Docker-related artifacts after uninstallation, revisit the steps above and ensure you followed each one carefully.

C. Recovery from Unintended Data Loss:

  • If you accidentally deleted containers or images you wanted to keep, refer to your backups for recovery.


In conclusion, Docker has been a game-changer in the world of software development and deployment, but there may come a time when you need to part ways with it. Uninstalling Docker from your Linux system is a meticulous process, but with this guide, you have all the steps and knowledge needed to do it right. Remember to back up your data, follow the steps carefully, and clean up your system thoroughly. Whether you’re switching to an alternative containerization solution or just decluttering, this guide has you covered.

Back to top button