How To Uninstall Docker Linux – Removing Docker From Linux Properly

Docker on Linux can be removed by purging its packages and deleting residual configuration files. If you are searching for how to uninstall docker linux, you likely want a clean removal without leftover traces. This guide walks you through the complete process step by step.

Removing Docker isn’t just about deleting a few files. You need to stop services, remove packages, and clear data directories. We cover all methods for popular distributions like Ubuntu, Debian, Fedora, and CentOS.

Why Uninstall Docker On Linux

You might need to uninstall Docker for several reasons. Perhaps you are switching to Podman or another container runtime. Maybe you have a broken installation that needs a fresh start.

Sometimes Docker conflicts with other software on your system. Or you simply want to free up disk space. Whatever your reason, this guide ensures a thorough removal.

Prerequisites Before Uninstalling

Before you begin, make sure you have sudo or root access. You will need administrative privileges to remove system packages.

Back up any important containers or images you want to keep. Uninstalling Docker removes all containers, images, and volumes by default.

  • Check your current Docker version with docker --version
  • List running containers with docker ps
  • Export important data before proceeding

How To Uninstall Docker Linux

This section covers the exact steps for removing Docker from different Linux distributions. Follow the instructions for your specific system.

Stop Docker Services First

Always stop Docker services before uninstalling. This prevents conflicts during package removal.

  1. Run sudo systemctl stop docker
  2. Disable Docker from starting on boot: sudo systemctl disable docker
  3. Verify the service is stopped: sudo systemctl status docker

If you use Docker Compose or other Docker-related services, stop them too. Check for docker.socket and stop it as well.

Remove Docker Packages On Ubuntu Or Debian

For systems using apt package manager, the removal process is straightforward. Use the purge command to remove packages and configuration files.

  1. List installed Docker packages: dpkg -l | grep docker
  2. Purge all Docker packages: sudo apt purge -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
  3. Remove any leftover dependencies: sudo apt autoremove -y
  4. Update package index: sudo apt update

If you installed Docker from the official repository, the package names might vary. Use dpkg -l | grep docker to identify exact names.

Remove Docker Packages On Fedora Or CentOS

For systems using yum or dnf, the process is similar but uses different commands.

  1. List installed Docker packages: rpm -qa | grep docker
  2. Remove Docker packages: sudo dnf remove docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
  3. For older CentOS versions: sudo yum remove docker-ce docker-ce-cli containerd.io
  4. Clean up dependencies: sudo dnf autoremove

Fedora and CentOS might have additional Docker-related packages. Check for docker-selinux or docker-engine packages.

Delete Docker Data And Configuration Files

Removing packages does not delete your Docker data. Images, containers, volumes, and configuration files remain on disk.

To completely remove all Docker data, delete these directories:

  • /var/lib/docker/ – Contains images, containers, volumes
  • /var/lib/containerd/ – containerd data
  • /etc/docker/ – Docker configuration files
  • ~/.docker/ – User-level Docker configuration

Run these commands to remove them:

sudo rm -rf /var/lib/docker/
sudo rm -rf /var/lib/containerd/
sudo rm -rf /etc/docker/
rm -rf ~/.docker/

Be careful with these commands. Deleting /var/lib/docker/ removes all your containers and images permanently.

Remove Docker Repository From System

Docker installations often add a repository to your system. Removing it prevents accidental reinstallation.

For apt-based systems:

  1. Remove the repository file: sudo rm /etc/apt/sources.list.d/docker.list
  2. Remove the GPG key: sudo rm /etc/apt/keyrings/docker.gpg
  3. Update package index: sudo apt update

For yum/dnf systems:

  1. Remove the repository file: sudo rm /etc/yum.repos.d/docker-ce.repo
  2. Clean cache: sudo dnf clean all

Verify Docker Is Completely Removed

After uninstalling, verify that Docker is gone. Run these checks to confirm complete removal.

  • Check if docker command exists: which docker (should return nothing)
  • Check for Docker processes: ps aux | grep docker
  • Check for Docker sockets: ls /var/run/docker.sock (should not exist)
  • Check for Docker group: getent group docker (may still exist but is harmless)

If any Docker-related files remain, remove them manually. A clean system should have no Docker traces.

Alternative Uninstall Methods

Sometimes the standard removal process does not work. Here are alternative methods for stubborn installations.

Using Docker’s Official Uninstall Script

Docker provides an official script for removal. This script handles many edge cases.

  1. Download the script: curl -fsSL https://get.docker.com -o get-docker.sh
  2. Run the uninstall: sudo sh get-docker.sh --uninstall
  3. Follow the prompts to complete removal

This script removes Docker packages and data. It works on most Linux distributions.

Manual Removal Of Docker Binaries

If you installed Docker from binaries or snap, you need manual removal. Snap installations require different steps.

For snap installations:

  1. Remove Docker snap: sudo snap remove docker
  2. Check for leftover data: ls /var/snap/docker/
  3. Remove snap data if needed: sudo rm -rf /var/snap/docker/

For binary installations, locate and delete the Docker binaries manually. Common locations include /usr/bin/docker and /usr/local/bin/docker.

Common Issues During Uninstall

You might encounter problems while uninstalling Docker. Here are solutions to frequent issues.

Package Removal Fails Due To Dependencies

Sometimes package managers refuse to remove Docker due to dependency conflicts. Force removal with these commands.

For apt: sudo dpkg --remove --force-remove-reinstreq docker-ce

For rpm: sudo rpm -e --nodeps docker-ce

After force removal, clean up with sudo apt autoremove or sudo dnf autoremove.

Docker Service Still Running

If Docker refuses to stop, use the kill command. Find the process ID and terminate it.

  1. Find Docker processes: ps aux | grep docker
  2. Kill the main process: sudo kill -9 [PID]
  3. Kill containerd if needed: sudo kill -9 [containerd PID]

After killing processes, proceed with package removal.

Leftover Network Interfaces

Docker creates virtual network interfaces. These might remain after uninstallation.

Remove Docker networks:

sudo ip link delete docker0
sudo ip link delete docker_gwbridge

Check for other Docker interfaces with ip link show and delete them similarly.

Clean Up User Permissions

Docker adds your user to the docker group during installation. Remove this group to restore security.

  1. Remove user from docker group: sudo gpasswd -d $USER docker
  2. Delete the docker group: sudo groupdel docker
  3. Log out and log back in for changes to take effect

Leaving the docker group active can cause permission issues with other tools.

Reinstalling Docker After Uninstall

If you removed Docker to reinstall it fresh, follow these steps. A clean install avoids previous configuration issues.

  1. Add the official Docker repository
  2. Install Docker using your package manager
  3. Start Docker service: sudo systemctl start docker
  4. Verify installation: docker --version

Make sure you do not restore old configuration files. Start with a fresh /etc/docker/ directory.

Frequently Asked Questions

How Do I Uninstall Docker Completely From Ubuntu?

Use sudo apt purge docker-ce docker-ce-cli containerd.io followed by sudo rm -rf /var/lib/docker/. This removes packages and data completely.

Does Uninstalling Docker Remove My Containers?

Yes, if you delete /var/lib/docker/. Without deleting that directory, containers remain but become inaccessible.

Can I Uninstall Docker Without Sudo?

No, you need root privileges to remove system packages and directories. Use sudo or switch to root user.

What Is The Difference Between Remove And Purge?

Remove deletes the package but keeps configuration files. Purge removes both the package and its configuration files.

How Do I Check If Docker Is Still Installed?

Run which docker or docker --version. If these return nothing, Docker is not installed.

Final Thoughts On Uninstalling Docker

Removing Docker from Linux is straightforward when you follow the right steps. Always stop services first, purge packages, and delete data directories.

Remember to backup important data before uninstalling. Once you delete /var/lib/docker/, your containers and images are gone forever.

If you plan to reinstall Docker later, consider keeping the repository in place. This saves you from re-adding it later.

For most users, the standard apt or dnf removal process works perfectly. Use the official uninstall script if you encounter problems.

After uninstalling, your system should be clean of Docker traces. Verify with the checks mentioned earlier to ensure complete removal.

Docker is a powerful tool, but sometimes you need to remove it. Whether for troubleshooting, switching tools, or freeing space, this guide helps you do it right.

If you have any issues during the process, consult the Docker documentation or community forums. Most problems have simple solutions.

We hope this guide on how to uninstall docker linux was helpful. Follow the steps carefully for a clean removal every time.