Docker Daemon Fails to Start - "unable to configure ... invalid daemon.json" in CI
The Docker daemon refused to start because /etc/docker/daemon.json is invalid JSON or sets an option that conflicts with a command-line flag. Until the config parses cleanly, dockerd will not come up and every docker command fails to connect.
What this error means
dockerd exits at startup with unable to configure the Docker daemon with file /etc/docker/daemon.json (a JSON parse error) or the following directives are specified both as a flag and in the configuration file. No docker commands work because the daemon never started.
unable to configure the Docker daemon with file /etc/docker/daemon.json:
invalid character '}' looking for beginning of object key string
# or a flag/config conflict:
unable to configure the Docker daemon ... hosts: (from flag: ..., from file: ...)Common causes
Malformed JSON in daemon.json
A trailing comma, missing quote, or stray brace makes daemon.json invalid JSON, so the daemon cannot parse its config and refuses to start.
A directive set both as a flag and in the file
Options like hosts/-H specified both on the dockerd command line and in daemon.json conflict, and the daemon aborts rather than guess.
An unknown or unsupported key
A misspelled or version-unsupported config key causes the daemon to reject the file at startup.
How to fix it
Validate and fix the JSON
Confirm daemon.json is well-formed before restarting the daemon.
python3 -c "import json;json.load(open('/etc/docker/daemon.json'))" && echo OK
sudo systemctl restart dockerResolve flag/config conflicts
- Choose one place for each option - either the systemd unit/flags or
daemon.json, not both. - Remove duplicated directives (commonly
hosts/-H) from one side. - Check
journalctl -u dockerfor the exact key the daemon rejected.
How to prevent it
- Lint
daemon.jsonas JSON in CI before applying it. - Keep each daemon option in a single source (flags or the file).
- Pin to documented config keys for your Docker version.