This error occurs when Docker cannot parse or apply settings from daemon.json due to JSON syntax errors, conflicting configuration options, permission issues, or invalid values. The fix depends on whether the conflict is between flags and config file settings, or a simple syntax issue.
When Docker starts, the daemon reads its configuration from `/etc/docker/daemon.json` (on Linux) or the equivalent location on Windows/macOS. This JSON file allows you to configure logging drivers, storage options, network settings, and many other daemon behaviors without modifying service files. The "unable to configure the Docker daemon with file" error indicates that Docker found and attempted to read the daemon.json file, but encountered a problem that prevents successful configuration. This could be: - **JSON syntax errors**: Invalid JSON formatting, missing commas, unclosed brackets, or trailing commas - **Configuration conflicts**: The same option is specified both in daemon.json AND as a command-line flag (most commonly the `hosts` option) - **Invalid values**: Using wrong data types (e.g., `"false"` as a string instead of `false` as a boolean) - **Permission issues**: The daemon cannot read the file due to filesystem permissions - **Reserved runtime names**: Using reserved names like "runc" in the runtimes configuration This is a critical error because Docker will refuse to start until the configuration issue is resolved, leaving you unable to run any containers.
First, get the exact error message to understand what's wrong:
On Linux (systemd):
sudo journalctl -u docker.service -n 50 --no-pagerOr check the service status:
sudo systemctl status docker.serviceOn Windows (Docker Desktop):
Check the Docker Desktop troubleshooting logs or Event Viewer.
Common error patterns to look for:
- EOF - Empty or truncated file
- json: cannot unmarshal - Wrong data type
- directives are specified both as a flag and in the configuration file: hosts - Configuration conflict
- configuration validation from file failed - Invalid configuration value
- permission denied - File access issue
The most common cause is invalid JSON. Validate your daemon.json file:
Using jq (recommended):
sudo cat /etc/docker/daemon.json | jq .If valid, it will pretty-print the JSON. If invalid, it will show the error location.
Using Python:
python3 -c "import json; json.load(open('/etc/docker/daemon.json'))"Using an online validator:
Copy the contents and paste into https://jsonlint.com/
Common JSON mistakes:
// WRONG - trailing comma
{
"storage-driver": "overlay2",
"log-driver": "json-file",
}
// CORRECT - no trailing comma
{
"storage-driver": "overlay2",
"log-driver": "json-file"
}// WRONG - missing comma between entries
{
"storage-driver": "overlay2"
"log-driver": "json-file"
}
// CORRECT - comma between entries
{
"storage-driver": "overlay2",
"log-driver": "json-file"
}If the error mentions EOF or the file is empty/blank, the file must contain at least an empty JSON object:
Check if file is empty:
sudo cat /etc/docker/daemon.jsonIf empty or doesn't exist, create it with valid content:
echo '{}' | sudo tee /etc/docker/daemon.jsonOr add some basic configuration:
cat << 'EOF' | sudo tee /etc/docker/daemon.json
{
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
}
}
EOFThen restart Docker:
sudo systemctl restart dockerThis is the most common conflict. On Debian/Ubuntu systems with systemd, Docker is started with a -H flag by default. If you also specify hosts in daemon.json, Docker fails.
Error message:
the following directives are specified both as a flag and in the configuration file: hostsSolution 1: Create a systemd override file
sudo mkdir -p /etc/systemd/system/docker.service.d
sudo cat << 'EOF' > /etc/systemd/system/docker.service.d/override.conf
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd
EOFThis clears the default -H flag, allowing daemon.json to control the hosts setting.
Reload and restart:
sudo systemctl daemon-reload
sudo systemctl restart dockerSolution 2: Use systemctl edit (interactive)
sudo systemctl edit docker.serviceAdd the same content as above, save, and restart.
Solution 3: Remove hosts from daemon.json
If you don't need remote access, simply remove the hosts key from daemon.json and use the default Unix socket.
JSON requires specific data types. Boolean values must not be quoted.
WRONG - strings instead of booleans:
{
"iptables": "false",
"live-restore": "true"
}CORRECT - actual booleans:
{
"iptables": false,
"live-restore": true
}WRONG - numbers as strings:
{
"max-concurrent-downloads": "3"
}CORRECT - actual numbers:
{
"max-concurrent-downloads": 3
}Refer to the Docker documentation for the correct type of each configuration option.
The Docker daemon runs as root and needs read access to daemon.json.
Check file permissions:
ls -la /etc/docker/daemon.jsonShould show something like:
-rw-r--r-- 1 root root 123 Jan 1 12:00 /etc/docker/daemon.jsonFix permissions if needed:
sudo chown root:root /etc/docker/daemon.json
sudo chmod 644 /etc/docker/daemon.jsonFor Docker installed via snap:
The config file location is different:
/var/snap/docker/current/config/daemon.jsonCheck AppArmor isn't blocking access:
sudo dmesg | grep -i apparmorIf you're configuring custom runtimes and see an error about reserved names:
Error:
runtime name 'runc' is reservedWRONG:
{
"runtimes": {
"runc": {
"path": "/usr/bin/runc"
}
}
}CORRECT - use a different name:
{
"runtimes": {
"custom-runc": {
"path": "/usr/local/bin/runc"
}
}
}The names "runc" and "io.containerd.runc.v2" are reserved by Docker.
Hidden characters or wrong encoding can cause parsing failures.
Check file encoding:
file /etc/docker/daemon.jsonShould show: ASCII text or UTF-8 Unicode text
If it shows UTF-16 or mentions BOM, convert it:
sudo iconv -f UTF-16 -t UTF-8 /etc/docker/daemon.json > /tmp/daemon.json
sudo mv /tmp/daemon.json /etc/docker/daemon.jsonCheck for hidden characters:
cat -A /etc/docker/daemon.jsonLook for unusual characters like ^M (carriage return) or non-printable characters.
Recreate the file from scratch:
If in doubt, delete and recreate:
sudo rm /etc/docker/daemon.json
sudo cat << 'EOF' > /etc/docker/daemon.json
{
"log-driver": "json-file"
}
EOFAfter making changes, validate and restart:
Validate JSON one more time:
sudo cat /etc/docker/daemon.json | jq .Restart Docker:
sudo systemctl daemon-reload # If you modified systemd files
sudo systemctl restart dockerVerify Docker is running:
sudo systemctl status docker
docker ps
docker infoCheck that your configuration is applied:
docker info | grep -i "logging driver"
docker info | grep -i "storage driver"The output should reflect the settings in your daemon.json.
### Understanding Docker Daemon Configuration Priority
Docker daemon configuration can come from multiple sources. Here's the priority order (highest to lowest):
1. Command-line flags (e.g., dockerd --storage-driver overlay2)
2. Environment variables (some options)
3. daemon.json configuration file
When the same option is specified in multiple places, Docker will either:
- Use the highest priority source (for most options)
- Fail with a conflict error (for the hosts option specifically)
### Common daemon.json Options
{
"storage-driver": "overlay2",
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
},
"live-restore": true,
"default-address-pools": [
{"base": "172.17.0.0/16", "size": 24}
],
"dns": ["8.8.8.8", "8.8.4.4"],
"max-concurrent-downloads": 3,
"max-concurrent-uploads": 5,
"debug": false,
"tls": true,
"tlscacert": "/etc/docker/ca.pem",
"tlscert": "/etc/docker/server-cert.pem",
"tlskey": "/etc/docker/server-key.pem"
}### Windows-Specific Issues
On Windows, daemon.json is typically located at:
- Docker Desktop: %USERPROFILE%\.docker\daemon.json or via Docker Desktop settings UI
- Docker Engine: C:\ProgramData\Docker\config\daemon.json
The group option conflict is common on Windows when Docker Desktop sets a default group that conflicts with daemon.json settings.
### macOS-Specific Issues
On macOS with Docker Desktop, configuration is managed through the Docker Desktop UI. The daemon.json file is at:
~/.docker/daemon.jsonBe careful editing this file directly as Docker Desktop may override your changes.
### Proxy Configuration (Docker Engine 23.0+)
In Docker Engine 23.0 and later, you can configure proxy settings in daemon.json:
{
"proxies": {
"http-proxy": "http://proxy.example.com:3128",
"https-proxy": "http://proxy.example.com:3128",
"no-proxy": "localhost,127.0.0.1,.example.com"
}
}Note: Earlier versions required configuring proxies via systemd environment files.
### Backup and Recovery
Always backup your daemon.json before making changes:
sudo cp /etc/docker/daemon.json /etc/docker/daemon.json.backupIf Docker won't start, you can temporarily move the file:
sudo mv /etc/docker/daemon.json /etc/docker/daemon.json.broken
sudo systemctl restart docker
# Docker should start with defaults
# Then fix daemon.json.broken and restore### Validating Configuration Before Applying
You can test configuration without restarting Docker by using:
dockerd --validate --config-file /etc/docker/daemon.jsonThis validates the configuration file without starting the daemon.
docker: Error response from daemon: OCI runtime create failed: container_linux.go: starting container process caused: exec: "/docker-entrypoint.sh": stat /docker-entrypoint.sh: no such file or directory
How to fix 'exec: entrypoint.sh: no such file or directory' in Docker
image operating system "linux" cannot be used on this platform
How to fix 'image operating system linux cannot be used on this platform' in Docker
dockerfile parse error line 5: unknown instruction: RRUN
How to fix 'unknown instruction' Dockerfile parse error in Docker
manifest unknown: manifest unknown
How to fix 'manifest unknown' in Docker
cannot open '/etc/passwd': Permission denied
How to fix 'cannot open: Permission denied' in Docker