How to fix docker: Error response from daemon (exit status 125) in Docker
Docker exit code 125 occurs when the docker run command itself fails before the container can start. This typically indicates a problem with the Docker daemon, invalid command syntax, or system resource conflicts.
Quick fix
Fixes 125
# On Linux
sudo systemctl status docker
# Or try
docker info- Check if Docker daemon is running
- Run the command manually to see the full error
- Remove conflicting containers
- Verify image availability
# On Linuxsudo systemctl status docker# Or trydocker infodocker: Error response from daemon (exit status 125)
What this error means
Exit code 125 is Docker's way of signaling that the `docker run` command failed at the daemon level, before the container could even start executing. Unlike exit codes from the container itself (which indicate application failures), exit code 125 means Docker encountered a problem with how the container was being launched. This error originates from the Docker daemon and indicates one of several possible issues: invalid command-line flags, permission problems, resource conflicts, or missing prerequisites. The actual root cause is often revealed in the full error message that accompanies the exit code. Understanding exit code 125 is important because it requires troubleshooting Docker's configuration and environment, rather than the application inside the container.
Typical symptoms
- Docker run command fails immediately with 'Error response from daemon: exit status 125'
- Container never starts despite command appearing correct
- Error message about container name conflicts or 'already in use'
- Network configuration errors mentioning invalid addresses
- CPU or resource allocation warnings from Docker daemon
- File sharing or volume mount permission errors (Windows/Mac)
Common causes
- Container name already exists from a previous run
- Invalid network configuration or IP address assignment
- Docker daemon is not running or not responding
- CPU resource limits exceed available system resources
- Missing or removed Docker images from local repository
- Invalid command-line flags or incorrect syntax in docker run
- File sharing permissions not configured (Docker Desktop)
- Insufficient user permissions to create containers
- Volume mount paths not accessible or shared
How to fix "docker: Error response from daemon (exit status 125)"
First, verify the Docker daemon is active and responding:
# On Linux
sudo systemctl status docker
# Or try
docker infoIf Docker is not running, start it:
# On Linux
sudo systemctl start docker
# On Mac/Windows
# Start Docker Desktop applicationExecute your docker run command directly in the terminal to see the complete error message. Exit code 125 is generic, but the accompanying message reveals the actual problem:
docker run [your-options] [image-name]Look for specific errors like:
- "Conflict. The container name is already in use"
- "Invalid address X.X.X.X: It does not belong to any of this network's subnets"
- "Range of CPUs is from 0.01 to X.XX, as there are only X CPUs available"
- "user declined directory sharing"
If the error mentions a container name conflict, list and remove the existing container:
# List all containers (including stopped ones)
docker ps -a
# Remove the conflicting container
docker rm <container-name>
# Or remove all stopped containers
docker container pruneTo prevent this issue, use the --rm flag to automatically remove containers on exit:
docker run --rm [other-options] [image-name]Check if the Docker image exists locally:
docker imagesIf the image is missing (possibly removed by docker system prune), pull it again:
docker pull [image-name]If the error mentions network problems:
# List networks
docker network ls
# Inspect the network
docker network inspect [network-name]
# Remove and recreate if needed
docker network rm [network-name]
docker network create [network-name]If manually specifying an IP address, ensure it belongs to the network's subnet range.
On Windows or Mac, if you see "user declined directory sharing":
1. Open Docker Desktop
2. Go to Settings → Resources → File Sharing
3. Add the directory path that contains your volumes or bind mounts
4. Click "Apply & Restart"
On Windows, ensure the drive is shared in Docker Desktop settings.
If the error mentions CPU constraints, either:
Option 1: Reduce the CPU limit in your docker run command:
docker run --cpus="1.0" [image-name]Option 2: Increase Docker Desktop's CPU allocation (Mac/Windows):
1. Open Docker Desktop → Settings → Resources
2. Increase CPUs and Memory sliders
3. Apply & Restart
If none of the above work, try resetting Docker:
# Restart Docker daemon (Linux)
sudo systemctl restart docker
# Or reset containers and networks
docker container prune
docker network prune
docker volume pruneOn Docker Desktop (Mac/Windows), use "Troubleshoot → Reset to factory defaults" as a last resort (this will remove all containers, images, and volumes).
Advanced notes
Understanding Docker Exit Codes: Exit codes 125-127 are reserved for Docker daemon errors, not application errors. Exit code 125 specifically means docker run failed, exit code 126 means the container command can't be invoked (not executable), and exit code 127 means the command wasn't found.
Windows-Specific Issues: Windows containers switching to Linux containers or vice versa can cause exit code 125. You may need to switch container modes in Docker Desktop and restart.
Hyper-V/Virtualization: On Windows, exit code 125 can occur if Hyper-V or WSL 2 backend is not properly configured. Ensure virtualization is enabled in BIOS and the required Windows features are installed.
CI/CD Environments: In automated pipelines, exit code 125 often indicates missing configuration (environment variables, secrets, network access). Check that the CI runner has proper Docker daemon access and sufficient resources.
Repository Name Validation: Docker requires repository names to be lowercase. If your project name or image tag contains uppercase letters, you'll get exit code 125 with "invalid reference format". Always use lowercase in image names.
Frequently asked questions
- What does "125" mean?
- Exit code 125 is Docker's way of signaling that the docker run command failed at the daemon level, before the container could even start executing. Unlike exit codes from the container itself (which indicate application failures), exit code 125 means Docker encountered a problem with how the container was being launched. This error originates from the Docker daemon and indicates one of several possible issues: invalid command-line flags, permission problems, resource conflicts, or missing prerequisites.
- How do I fix "125"?
- Docker exit code 125 occurs when the docker run command itself fails before the container can start. This typically indicates a problem with the Docker daemon, invalid command syntax, or system resource conflicts.
- What causes "125"?
- Container name already exists from a previous run Invalid network configuration or IP address assignment Docker daemon is not running or not responding
- Is the "125" error serious?
- It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- 📚Docker Official Documentation
- 📖Docker Run Reference - Exit Status(Official Docs)
- 💬Stack Overflow - Docker Exit Codes(Stack Overflow)
- 💬Stack Overflow - Exit Code 125 Solutions(Stack Overflow)
- 📖Exit Code 125 Explained Guide(Official Docs)
- 📖Exit Codes in Docker and Kubernetes(Official Docs)