Remove docker.io and containerd Completely on Ubuntu/Debian

How to Completely Remove docker.io and containerd (Configs, Data & Services)

This guide walks you through a full removal of Docker and containerd on Debian/Ubuntu systems like including services, packages, configuration directories, and cached data, so you can start from a clean slate.

Before You Begin

  • Scope: Commands target Debian/Ubuntu (APT-based) systems.
  • Destructive: You will permanently remove Docker/containerd data and images. Back up anything you need first.
  • Root privileges: Use sudo or run as root.

1) Stop & Disable Services

Stop any running Docker/containerd services and prevent them from starting again:

sudo systemctl stop docker
sudo systemctl disable docker
sudo systemctl stop containerd
sudo systemctl disable containerd

Why: Stopping services ensures files and sockets can be removed cleanly, and disabling prevents automatic restarts.

2) Uninstall Packages

Remove the packages and their config files using apt purge:

# Uninstall docker.io
sudo apt purge docker.io -y

# Uninstall containerd
sudo apt purge containerd -y

Why: purge removes both binaries and package-managed configs under /etc.

3) Delete Residual Files & Directories

Clean up any leftover runtime/data/config directories:

# Docker directories
sudo rm -rf /etc/docker
sudo rm -rf /var/lib/docker
sudo rm -rf /var/run/docker.sock
sudo rm -rf /var/log/docker
sudo rm -rf /var/lib/containerd

# containerd directories
sudo rm -rf /etc/containerd
sudo rm -rf /var/lib/containerd
sudo rm -rf /var/run/containerd
sudo rm -rf /var/log/containerd

Why: Package removal does not always delete runtime/state. These paths hold images, layers, logs, and sockets.

4) Remove Orphaned Dependencies

Clean up packages that were only installed to satisfy Docker/containerd dependencies:

sudo apt autoremove

5) Verify Cleanup

Double-check for any stragglers:

# Processes (should return only the grep command or nothing)
ps aux | grep -E ''docker|containerd''

# Expected directories should be empty/missing
ls /etc | grep -E ''docker|containerd'' || true
ls /var/lib | grep -E ''docker|containerd'' || true

If anything remains, investigate and remove manually.

6) Final Clean

Clear the package cache to free space:

sudo apt clean

Summary

After completing these steps, all Docker/containerd components, configs, and data should be removed. You can now reinstall Docker or another runtime on a clean base—ideal for troubleshooting, re-provisioning, or switching engines.

Tested on recent Ubuntu LTS releases. Commands are destructive—proceed with caution.