Docker: Cannot connect to the Docker daemon at. Is the docker daemon running?
I downloaded and installed the Docker desktop(Intel chip) for Mac from the official website. Once run the docker desktop, I tried several docker commands in the terminal and all of them failed with the following error.
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Why is this error?
The error “docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the Docker daemon running?” occurs when the Docker command-line interface (CLI) is unable to communicate with the Docker daemon. The Docker daemon is the background process responsible for managing Docker containers on your system.
Here’s a breakdown of the components of the error message
docker: Indicates that the error is related to the Docker CLI.
Cannot connect to the Docker daemon: Specifies that the Docker CLI is unable to establish a connection with the Docker daemon.
unix:///var/run/docker.sock: Represents the default Unix socket used for communication between the Docker CLI and the Docker daemon.
Is the Docker daemon running?: Asks whether the Docker daemon is currently active and operational.
To resolve this issue, consider the following steps
Check Docker Daemon Status: Verify whether the Docker daemon is running on your system. You can do this by running:
sudo systemctl status docker
If it’s not running, start the Docker daemon using:
sudo systemctl start docker
User Permissions: Ensure that the user running the Docker command has the necessary permissions to access the Docker daemon. You may need to add the user to the docker
group:
sudo usermod -aG docker $USER
After making this change, you may need to log out and log back in for the group changes to take effect.
Docker Daemon Restart: Restart the Docker daemon to apply any changes:
sudo systemctl restart docker
Socket File Existence: Confirm that the Docker socket file /var/run/docker.sock
exists. If it’s missing, it could indicate a problem with the Docker installation.
Reinstall Docker: If the issue persists, consider reinstalling Docker on your system.
After performing these checks and steps, you should be able to resolve the “docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the Docker daemon running?” error.
Comments
-
Danielle Carline
Posted on
Sometimes, this might happen if you skip the license agreement that is displayed when you run the Docker desktop for the first time in MacOS. If the above steps are not helpful, try the following these steps.
Step 1: Uninstall Docker Desktop
Uninstall Docker DesktopStep 2: Once uninstallation has been completed, cd to where you have Docker.dmg. In my case, it is in Downloads
cd Downloads
Step 3: Install Docker desktop running these commands from the official documentation.
sudo hdiutil attach Docker.dmg sudo /Volumes/Docker/Docker.app/Contents/MacOS/install sudo hdiutil detach /Volumes/Docker
Step 4: Once installed, run Docker Desktop, Accept the License agreement and Click on finish.
Docker DesktopStep 5: Then you will be able to run any docker command. For example,
docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES