Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker: Cannot connect to the Docker daemon on Mac OS X

Tags:

docker

I got the following error when I run docker. Does anybody know how to fix the problem. The OS is Mac OS X.

$ docker --version
Docker version 17.12.0-ce, build c97c6d6
$ docker run hello-world
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.
like image 867
user1424739 Avatar asked Sep 13 '25 15:09

user1424739


2 Answers

You can restart Docker with the following

Stop Docker for Mac gracefully

Stop all Docker containers without confirmation (make sure nothing is running in Docker)

docker ps -q | xargs -L1 docker stop

Requires all Docker containers are stopped

test -z "$(docker ps -q 2>/dev/null)" && osascript -e 'quit app "Docker"'

Start Docker gracefully

open --background -a Docker
like image 101
zero_cool Avatar answered Sep 16 '25 08:09

zero_cool


This is the answer with the least effort but it helped to solve my problem which I was debugging for a couple of hours: Reboot your macOS.

like image 38
wintermeyer Avatar answered Sep 16 '25 08:09

wintermeyer