error docker
Docker Exit Code 125 - Docker Daemon Error
Understanding Docker exit code 125 - the Docker daemon encountered an error before the container process could start.
What It Means
Docker exit code 125 indicates that the Docker daemon itself encountered an error. The container’s process never started — the failure occurred at the Docker level before the application could run. This distinguishes it from exit code 1 (application error) and exit codes 126/127 (command issues).
Common Causes
- Invalid Docker run flags or options
- Port already in use (cannot bind)
- Volume mount path does not exist
- Insufficient permissions to access resources
- Invalid container configuration
- Image not found and cannot be pulled
- Docker daemon resource limits exceeded
- Invalid network configuration
- SELinux or AppArmor denying container operations
How to Fix
Check the error message
# Docker usually prints a descriptive error
docker run my-image
# Error response from daemon: ...
# Get more details with verbose output
docker --debug run my-image
Fix port conflicts
# Error: port is already allocated
docker run -p 3000:3000 my-image
# Error: bind: address already in use
# Find what's using the port
lsof -i :3000
# or
ss -tlnp | grep 3000
# Use a different host port
docker run -p 3001:3000 my-image
Fix volume mount issues
# Error: invalid mount path
docker run -v /nonexistent/path:/app/data my-image
# Ensure the host path exists
mkdir -p /path/to/data
docker run -v /path/to/data:/app/data my-image
# Fix permissions on mounted volumes
docker run -v /path/to/data:/app/data -u $(id -u):$(id -g) my-image
Fix image issues
# Error: image not found
docker run nonexistent-image:latest
# Pull the image first
docker pull my-image:latest
# Check if the image exists locally
docker images | grep my-image
# Try with full registry path
docker run registry.example.com/my-image:latest
Fix invalid flags
# Wrong: invalid flag combinations
docker run --network=host -p 3000:3000 my-image # Can't use -p with host network
# Right: pick one network strategy
docker run --network=host my-image
# or
docker run -p 3000:3000 my-image
Fix Docker Compose issues
# Validate your docker-compose.yml
# docker compose config
services:
app:
image: my-image
ports:
- "3000:3000"
volumes:
- ./data:/app/data # Ensure ./data exists
environment:
- NODE_ENV=production
Related Errors
- Docker Exit Code 1 - Application error: The container started but the app crashed.
- Docker Exit Code 126 - Command not executable: The entrypoint or CMD is not executable.
- Docker Exit Code 127 - Command not found: The entrypoint or CMD binary was not found.