Docker
Troubleshooting
Error Code
Docker Service
System Administration

Docker How to fix Job for docker.service failed because the control process exited with error code

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

When Docker refuses to start on Linux and you see "Job for docker.service failed because the control process exited with error code," it means the Docker daemon crashed during startup. This is frustrating because the error message itself tells you almost nothing about the root cause. The fix depends on reading the actual logs and identifying which of several common problems is preventing the daemon from initializing.

Checking the Logs

Your first step is always to read the detailed error output. The one-line systemd message is just a wrapper. The real information is in the journal and the Docker log file.

bash
1# View the full systemd journal for the Docker service
2sudo journalctl -u docker.service --no-pager -n 50
3
4# Check the Docker daemon log directly
5sudo cat /var/log/docker.log
6
7# If the above file doesn't exist, try the journal with extra detail
8sudo journalctl -xeu docker.service

Look for lines containing "error", "fatal", or "failed" near the end of the output. The specific error message determines which fix to apply.

Cause 1 -- daemon.json Syntax Error

The most common cause is a malformed /etc/docker/daemon.json file. A single missing comma, trailing comma, or unquoted key will prevent the daemon from starting.

bash
# Validate the JSON syntax
python3 -m json.tool /etc/docker/daemon.json

If this command reports an error, fix the syntax. Here is an example of a correct daemon.json:

json
1{
2  "storage-driver": "overlay2",
3  "log-driver": "json-file",
4  "log-opts": {
5    "max-size": "10m",
6    "max-file": "3"
7  }
8}

Common JSON mistakes include trailing commas after the last item in an object, single quotes instead of double quotes, and comments (JSON does not support comments).

Cause 2 -- Storage Driver Issues

If the logs mention "failed to start daemon" with references to "overlay2", "devicemapper", or "aufs", the storage driver is misconfigured or the required kernel module is not loaded.

bash
1# Check which storage drivers are available
2sudo docker info 2>&1 | grep "Storage Driver" || true
3
4# Verify the overlay module is loaded
5lsmod | grep overlay
6
7# Load it if missing
8sudo modprobe overlay

If you recently changed the storage driver in daemon.json, Docker cannot read images created with the old driver. Either remove the setting to use the default, or clear the old data directory:

bash
1# Back up first, then remove old Docker data
2sudo systemctl stop docker
3sudo mv /var/lib/docker /var/lib/docker.backup
4sudo systemctl start docker

Cause 3 -- Disk Space Exhaustion

Docker will fail to start if the partition containing /var/lib/docker is full.

bash
1# Check disk usage
2df -h /var/lib/docker
3
4# Find large files if the disk is full
5sudo du -sh /var/lib/docker/* | sort -rh | head -10

Free space by pruning unused images, containers, and volumes:

bash
# Remove stopped containers, unused images, and build cache
sudo docker system prune -a --volumes

If Docker will not start at all, you may need to manually remove files from /var/lib/docker/tmp or clear old container logs under /var/lib/docker/containers/.

Cause 4 -- Conflicting Installations

Installing Docker from multiple sources (for example, both the Ubuntu docker.io package and Docker's official repository) causes file conflicts and broken systemd units.

bash
1# Check for multiple Docker packages
2dpkg -l | grep -i docker
3
4# You should see only docker-ce, docker-ce-cli, and containerd.io
5# If you see docker.io alongside docker-ce, remove the conflicting package
6sudo apt-get remove docker.io

Cause 5 -- Socket Permission or Leftover PID File

Sometimes a stale PID file or socket prevents the daemon from starting:

bash
1# Remove stale files
2sudo rm -f /var/run/docker.pid
3sudo rm -f /var/run/docker.sock
4
5# Restart
6sudo systemctl start docker

Applying the Fix and Restarting

After fixing the underlying issue, always reload the systemd configuration before restarting:

bash
1# Reload systemd daemon configs (required after editing unit files)
2sudo systemctl daemon-reload
3
4# Start Docker
5sudo systemctl start docker
6
7# Verify it is running
8sudo systemctl status docker
9
10# Run a quick test
11sudo docker run hello-world

If the service starts but fails again after a reboot, make sure Docker is enabled:

bash
sudo systemctl enable docker

Clean Reinstall Steps

If none of the above fixes work, a clean reinstall often resolves the issue. This removes all Docker data including images and containers:

bash
1# Stop and remove Docker
2sudo systemctl stop docker
3sudo apt-get purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
4sudo rm -rf /var/lib/docker
5sudo rm -rf /var/lib/containerd
6sudo rm -rf /etc/docker
7
8# Reinstall from Docker's official repository
9sudo apt-get update
10sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
11
12# Start and verify
13sudo systemctl start docker
14sudo docker run hello-world

Common Pitfalls

  • Skipping the logs and guessing: The journal output tells you exactly what went wrong. Always read journalctl -xeu docker.service before trying random fixes.
  • Editing daemon.json without validating JSON: A trailing comma or missing brace silently breaks Docker startup. Always validate with python3 -m json.tool after editing.
  • Forgetting systemctl daemon-reload: After modifying systemd unit files or Docker's configuration, systemd must reload its cache. Skipping this step means your changes have no effect.
  • Mixing Docker installation sources: Having both docker.io (distro package) and docker-ce (official Docker package) installed creates conflicts. Pick one source and remove the other.
  • Deleting /var/lib/docker without a backup: This removes all images, containers, and volumes. Always back up or confirm you can rebuild before deleting.

Summary

  • Always start by reading the actual logs with journalctl -xeu docker.service rather than guessing from the generic error message.
  • The most common causes are a malformed daemon.json, storage driver misconfiguration, disk space exhaustion, conflicting package installations, and stale PID or socket files.
  • After fixing the root cause, run systemctl daemon-reload followed by systemctl start docker to restart the service.
  • If all else fails, a clean uninstall and reinstall from Docker's official repository resolves most persistent issues.
  • Always validate configuration files and check disk space before assuming the problem is complex.

Course illustration
Course illustration

All Rights Reserved.