I spent a good couple of hours trying to fix this error message. I have the latest version of Docker installed on my Mac M1 Max running Sonoma 14.3.1.
Every time I run a command that had to connect to the deamon, I was getting the same exact error:
docker: Cannot connect to the Docker daemon at unix://Users/<user>/.docker/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.
This was not fun. But after a bit of googling (yes, ChatGPT etc couldn't help), I stumbled across the solution on this StackOverflow post
The cause of the problem is that at some point, Docker removed the /var/run/docker.sock
symlink in default behavior. If you're curions, you can find more details about this in the Docker release notes here or you can skip straight to the fix
The fix
We have to manually add a symlink You have to follow the steps below to fix the issue on your MacOS
- Quit the Docker Desktop app
- Open your terminal, copy-paste the following and press Enter
sudo ln -s ~/Library/Containers/com.docker.docker/Data/docker.raw.sock /var/run/docker.sock
3. Restart Docker Desktop
4. Run the following command to ensure that the symlink works
DOCKER_HOST=unix:///var/run/docker.sock docker ps
If everything worked as expected, the output should look similar to this: CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5. (optional) if you use zsh
then you also need to update your .zshrc
file and add the following setting:
export DOCKER_HOST=unix:///Users/$USER/Library/Containers/com.docker.docker/Data/docker.raw.sock
And that' all there is to it. Now, you're good to start interacting with your Docker deamon