Cannot connect to the Docker daemon
Docker cannot communicate with the Docker daemon because the daemon is stopped, inaccessible, or the current user lacks permission.
Usually happens because:
- ☑ Docker service is stopped
- ☑ Missing group user privileges on Unix socket
- ☑ Active Docker context pointing to wrong host
🔍 Quick Checklist:
What is Cannot connect to the Docker daemon?
The Docker daemon (dockerd) is the background service running on your host machine that manages all your Docker containers, images, networks, and volumes. When you run a command like 'docker ps' or 'docker run', the Docker client CLI sends a request to the daemon via a Unix socket (on Linux/macOS) or a named pipe (on Windows). If the daemon is stopped, crashed, or permissions to its interface socket are restricted, the client will fail to connect and display this error.
Common Causes
- Docker not running: The background service has not been started.
- Permission denied: The current terminal user is not part of the 'docker' user group.
- Wrong Docker context: The active Docker context points to a remote endpoint that is unreachable.
- Docker Desktop stopped: The GUI application is closed or not fully initialized on Windows or macOS.
- WSL integration issue: Windows Subsystem for Linux integration has been disabled inside Docker settings.
- Daemon crashed: The Docker daemon process encountered a fatal error and terminated.
| Cause | Frequency |
|---|---|
| Docker not running | ⭐⭐⭐⭐⭐ |
| Permission denied | ⭐⭐⭐⭐ |
| Wrong Docker context | ⭐⭐⭐ |
| Docker Desktop stopped | ⭐⭐⭐⭐ |
| WSL issue | ⭐⭐ |
| Daemon crashed | ⭐⭐ |
Common Mistakes
- Assuming installing the Docker CLI package automatically starts the backend daemon engine.
- Using multiple terminal profiles with mismatched environmental variables pointing to incorrect socket files.
How to Fix
Docker Operations & Verification
Compose commands also fail if the connection socket is closed.
$ docker compose up -d
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?Platform Specific Fixes
Standard systemd commands to manage Docker daemon services on Ubuntu/Debian/CentOS.
# Start Daemon
sudo systemctl start docker
# Enable on startup boot
sudo systemctl enable docker
# Restart Daemon
sudo systemctl restart dockerBest Practices
- Configure Docker to launch automatically on host boot cycles.
- Keep Docker Desktop application packages updated to minimize virtualization compatibility failures.
- Avoid running Docker commands exclusively using 'sudo' permissions as it can mess up localized cache folders.
Frequently Asked Questions (FAQ)
Q: Why can't Docker connect?
The client cannot communicate with the socket at /var/run/docker.sock, usually because the dockerd daemon process is stopped or permissions are restricted.
Q: Is Docker running?
You can check if Docker is running by executing 'docker info' or checking service status via systemctl status docker.
Q: How do I restart Docker?
On Linux, use 'sudo systemctl restart docker'. On Windows/macOS, restart Docker Desktop via the system tray icon.
Q: How do I check Docker daemon?
Review system logs using 'journalctl -u docker' or check the service state directly.
Q: Why is docker.sock permission denied?
By default, the Unix socket belongs to root. To connect without sudo, add your user to the 'docker' group.