• 1
name Punditsdkoslkdosdkoskdo

Cannot connect to the Docker daemon on macOS

I normally prefer to manage my apps on my OSX with brew

I am able to install docker, docker-compose and docker-machine

docker --version
Docker version 17.05.0-ce, build 89658be
docker-compose --version
docker-compose version 1.13.0, build unknown
docker-machine --version
docker-machine version 0.11.0, build 5b27455

I did not download and run 'Docker for Mac' app.

However when I try to run

> docker run -d -p 80:80 --name webserver nginx
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.

I have already checked the sock file

ls -lah /var/run/docker.sock /var/tmp/docker.sock
ls: /var/run/docker.sock: No such file or directory
ls: /var/tmp/docker.sock: No such file or directory


But I got this error message:

$ eval $(docker-machine env default)
Host does not exist: "default"

Is it possible to get a docker service to run by command line tools?


Because process management is inherently difficult with MacOS (unlike traditional *nix OS's with things like SystemD and init) You need a cask application to launch and run in the background to allow the daemon to run (and have easy management access).

brew install just installs CLI utilities brew cask install is intended for GUI utilities. Thus, when you install docker you must preform BOTH installs to get the daemon GUI utility and the CLI utility. I hope this clarifies for those that were upset about Brew not installing both by default!

  • 0
Reply Report