Skip to content
Cannot connect to the Docker daemon

Cannot connect to the Docker daemon

DodaTech 2 min read

The “Cannot connect to the Docker daemon” error means the Docker CLI can communicate with the Docker daemon socket but the daemon is not running or your user lacks permission. This is usually a service or permissions issue.

What It Means

The docker command tried to reach the Docker daemon via /var/run/docker.sock but the daemon was unreachable. The socket file may be missing, the daemon process may be stopped, or your user is not authorized to access the socket.

Why It Happens

  • The docker service is not started or has crashed.
  • The Docker daemon socket is not listening.
  • Your user is not in the docker group and is running without sudo.
  • The system was rebooted and Docker was not configured to start automatically.

How to Fix It

1. Start the Docker daemon

sudo systemctl start docker

Enable Docker to start on boot:

sudo systemctl enable docker

2. Check the daemon status

sudo systemctl status docker

Look for active (running) in the output. If it failed, inspect the logs:

journalctl -u docker --no-pager -n 50

3. Add your user to the docker group

sudo usermod -aG docker $USER

Important: Log out and log back in (or run newgrp docker) for the group change to take effect. Restart your terminal session.

4. Restart the socket (if applicable)

sudo systemctl restart docker.socket

5. Verify the fix

docker run hello-world

If you see the “Hello from Docker!” message, the daemon is reachable.

FAQs

Can I run Docker without sudo without adding my user to the docker group?
No. The Unix socket /var/run/docker.sock is owned by root:docker with permissions 660. Only the root user and members of the docker group can access it directly.
What if 'systemctl start docker' hangs?
Check for stale Docker lock files: sudo rm -f /var/lib/docker/engine-id /var/run/docker.pid and try again. You may also need to restart the entire Docker service with sudo systemctl restart docker.
What does 'permission denied while trying to connect to the Docker daemon socket' mean?
Your user does not have permission to read/write /var/run/docker.sock. Add yourself to the docker group with sudo usermod -aG docker $USER and then re-login.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro