🎉 DevOps Interview Prep Bundle is live — 1000+ Q&A across 20 topicsGet it →
All Articles

Docker Daemon Not Starting on Linux — Fix Guide

Docker daemon fails to start, or the systemd service crashes immediately. Here's how to diagnose dockerd startup failures from storage driver conflicts to corrupted config files.

DevOpsBoysMay 18, 20264 min read
Share:Tweet

You run docker ps and get: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Here's how to diagnose and fix it systematically.


Step 1 — Check Service Status

bash
# Check if Docker service is running
sudo systemctl status docker
 
# If stopped/failed, check why
sudo journalctl -u docker.service -n 50 --no-pager
 
# Try to start it manually
sudo systemctl start docker
 
# Check if it stays up
sudo systemctl status docker
sleep 3
sudo systemctl status docker

Fix 1 — Corrupted daemon.json

The most common cause. A bad JSON value in /etc/docker/daemon.json prevents startup.

bash
# Check if the file exists and is valid
cat /etc/docker/daemon.json
python3 -m json.tool /etc/docker/daemon.json
 
# If malformed JSON, you'll see: JSONDecodeError

Common broken daemon.json:

json
{
  "storage-driver": "overlay2",
  "insecure-registries": ["192.168.1.10:5000",]  // Trailing comma — invalid JSON!
}

Fix:

bash
# Validate and fix
cat /etc/docker/daemon.json | python3 -c "import sys,json; json.load(sys.stdin); print('Valid JSON')"
 
# Or just reset to defaults
sudo mv /etc/docker/daemon.json /etc/docker/daemon.json.bak
sudo systemctl start docker

Fix 2 — Storage Driver Conflict

bash
# Check journal for storage driver errors
sudo journalctl -u docker.service | grep -i "storage\|overlay\|devicemapper"
 
# Common error:
# "Error starting daemon: error initializing graphdriver: driver not supported"
# "overlay2: filesystem not supported on this kernel"

Fix:

bash
# Check what storage drivers are available
ls /proc/filesystems | grep overlay
 
# If overlay2 not in kernel modules, load it
sudo modprobe overlay
 
# Make permanent
echo "overlay" | sudo tee -a /etc/modules-load.d/docker.conf
 
# Check kernel version (overlay2 needs 4.0+)
uname -r

If still failing, switch storage driver:

json
// /etc/docker/daemon.json
{
  "storage-driver": "vfs"   // Fallback (slower but always works)
}

Fix 3 — Corrupted Docker Data Directory

bash
# Check for corruption errors in logs
sudo journalctl -u docker.service | grep -i "corrupt\|error\|failed"
 
# If metadata is corrupted, a clean restart may fix it
sudo systemctl stop docker
sudo rm -rf /var/lib/docker/tmp
sudo systemctl start docker

Last resort — wipe Docker data (DESTROYS ALL IMAGES, CONTAINERS, VOLUMES):

bash
sudo systemctl stop docker
sudo rm -rf /var/lib/docker
sudo systemctl start docker
 
# After this, Docker starts fresh — no images or containers

Fix 4 — Port Conflict (Docker Daemon Port)

bash
# Check if docker socket or port is already in use
sudo fuser /var/run/docker.sock
ls -la /var/run/docker.sock
 
# Remove stale socket
sudo rm /var/run/docker.sock
sudo systemctl start docker

Fix 5 — Disk Full

bash
# Check disk space
df -h /var/lib/docker
df -h /
 
# If full, clean up Docker objects
sudo docker system prune -a --volumes   # WARNING: removes all unused data
 
# Or just dangling images
sudo docker image prune
 
# Show what's taking space
sudo docker system df

Fix 6 — cgroup Version Mismatch

Common on newer Ubuntu/Debian systems:

bash
# Check cgroup version
stat -fc %T /sys/fs/cgroup/
 
# If output is "cgroup2fs" (cgroup v2), some older Docker configs break
# Check Docker logs for cgroup errors
sudo journalctl -u docker.service | grep cgroup

Fix for cgroup v2:

json
// /etc/docker/daemon.json
{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2"
}

Fix 7 — SELinux or AppArmor Blocking Docker

On RHEL/CentOS/Fedora with SELinux:

bash
# Check if SELinux is blocking
sudo ausearch -m avc -ts recent | grep docker
 
# Temporary fix (not for production)
sudo setenforce 0
sudo systemctl start docker
 
# Proper fix — set SELinux to permissive for docker
sudo setsebool -P container_manage_cgroup on

On Ubuntu with AppArmor:

bash
sudo aa-status | grep docker
sudo apparmor_parser -R /etc/apparmor.d/docker 2>/dev/null
sudo systemctl start docker

Full Diagnosis Script

bash
#!/bin/bash
echo "=== Docker Daemon Diagnosis ==="
 
echo -e "\n--- Service Status ---"
sudo systemctl status docker --no-pager
 
echo -e "\n--- Recent Logs ---"
sudo journalctl -u docker.service -n 20 --no-pager
 
echo -e "\n--- Disk Space ---"
df -h /var/lib/docker /
 
echo -e "\n--- daemon.json ---"
cat /etc/docker/daemon.json 2>/dev/null || echo "No daemon.json found"
 
echo -e "\n--- Storage Driver Modules ---"
lsmod | grep -E "overlay|dm_|btrfs"
 
echo -e "\n--- Docker Socket ---"
ls -la /var/run/docker.sock 2>/dev/null || echo "Socket not found"
 
echo -e "\n--- Kernel Version ---"
uname -r

After Docker Restarts Successfully

bash
# Verify Docker is working
docker info
docker run --rm hello-world
 
# Enable Docker to start on boot
sudo systemctl enable docker

For Docker troubleshooting and container operations, KodeKloud has hands-on Docker labs covering daemon configuration, storage drivers, and container networking.

Newsletter

Stay ahead of the curve

Get the latest DevOps, Kubernetes, AWS, and AI/ML guides delivered straight to your inbox. No spam — just practical engineering content.

Related Articles

Comments