Docker CLI cannot reach the Docker service
This is a fundamental connectivity error indicating that the Docker command-line interface (CLI) cannot communicate with the Docker daemon (the background service). This prevents all Docker operations, from building images to running containers.
- 1The Docker daemon service is not running on the host machine.
- 2A non-root user is trying to run Docker commands without the correct permissions (i.e., not being in the 'docker' group).
- 3The Docker daemon is configured to listen on a non-standard socket or TCP address, and the DOCKER_HOST environment variable is not set correctly.
- 4A system firewall is blocking communication to the Docker socket or TCP port.
On a fresh Linux installation, after installing Docker, a user tries to run their first Docker command before starting the service.
# (Assuming Docker daemon is not running) docker ps
expected output
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Fix 1
Start the Docker Service
WHEN The Docker daemon is stopped.
# On Linux with systemd sudo systemctl start docker sudo systemctl enable docker # On Windows/macOS # Launch the Docker Desktop application.
Why this works
This starts the core Docker engine, which listens for commands from the CLI.
Fix 2
Add User to the 'docker' Group
WHEN The error message includes 'permission denied' when accessing '/var/run/docker.sock'.
# Add the current user to the docker group sudo usermod -aG docker $USER # IMPORTANT: You must log out and log back in for this change to take effect. newgrp docker
Why this works
This grants the user's account the necessary file system permissions to communicate with the Docker daemon's Unix socket, avoiding the need for 'sudo' on every command.
✕ Change permissions of the docker socket file ('/var/run/docker.sock') to 777.
This is a security risk as it allows any user on the system to control the Docker daemon, effectively giving them root access to the host. Always manage access via group membership.
Docker post-installation steps
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev