Coding

macos cannot connect to the docker daemon at unix:///var/run/docker.sock. is the docker daemon running?

Is the docker daemon running mac? macos cannot connect to the docker daemon at unix:///var/run/docker.sock. is the docker daemon running?

Written by Ashok Kumar · 2 min read >
Can not Connect To the Docker Daemon

In today’s session, we are going to troubleshoot “Cannot connect to the Docker daemon on macOS”. It is one of the most common issues faced by a developer when he starts working with the docker. And one of the possible reasons which I can say is the way you have set up your docker environment, that is the most possible way you are getting this issue. 

The solution of MACOS cannot connect to the docker daemon at unix:///var/run/docker.sock. is the docker daemon running?

There are two ways to fix the Cannot connect to the docker daemon at unix:/var/run docker soc mac . One is recommended and one is like if you want to have a quick fix. So we’ll go through both ways and I’ll show you a demo also like why we get this error and how we can troubleshoot it. 

Okay, let’s head back to our terminal. And this is the error that I’m getting on my development laptop. And as you can see, this is the error message I am getting.

Actual behavior

Seeing error:

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

P.S. Can this command just fine:

docker run -d -p 80:80 docker/getting-started

Here are some steps that Can not Connect To The Docker Daemon error:

Please remind people that after usermod you need to reload the bash shell* exec su -l $USER

I would like to say, this error can happen with any docker command. So this error is not tightly bounded with any specific docker command. So as you can see below, I am trying explain step by step guide with commands.  

  1. Check if the Docker daemon is running:
Start Docker Desktop when you log in
lua
sudo systemctl status docker

If the Docker daemon is not running, you can start it by running:

sql
sudo systemctl start docker
  1. Check if your user account is added to the Docker group:

By default, only the root user and users in the “docker” group can access the Docker daemon. You can check if your user account is added to the “docker” group by running the following command:

bashCopy code

groups

bash
groups

If “docker” is not listed in the output, you can add your user account to the “docker” group by running the following command:

sql

sudo usermod -aG docker makeanapplike-user

Replace “makeanapplike-user” with your actual username.

  1. Check if the Docker socket file exists:

The Docker daemon listens for incoming requests on a Unix socket file located at “/var/run/docker.sock”. You can check if this file exists by running the following command:

bash
ls -la /var/run/docker.sock

If the file does not exist, you can create it by running the following command:

bash
sudo touch /var/run/docker.sock
  1. Restart the Docker daemon:

If none of the above steps work, you can try restarting the Docker daemon by running the following commands:

arduino

sudo systemctl stop docker
sudo systemctl start docker

This will stop and start the Docker daemon, which may help to fix any issues.

What other steps may usefull to fix the docker daemon issue?

This issue occurs due to permissions issue, either you are using Mac or Linux. Trying few command will fix the issue.

Docker is running
  1. Search Spotlight
  2. Type: Docker and open the App
  3. You would see it on your Apple Menu bar,
  4. Make sure you see: “Docker is running”
  1. Install intellij idea
  2. Install docker plugin
  3. Create docker connection

One user from our community said

I just had exactly the same problem, it disappeared after running the command:
sudo usermod -aG docker ${USER}
and instant reboot (I tried to logout/login few times, but only after rebooting my idea 2020.3 managed to connect to docker.sock) ubuntu 20.04

Written by Ashok Kumar
CEO, Founder, Marketing Head at Make An App Like. I am Writer at OutlookIndia.com, KhaleejTimes, DeccanHerald. Contact me to publish your content. Profile

Leave a Reply