Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 

I have also tried this proposed solution: Mac OS X sudo docker Cannot connect to the Docker daemon. Is the docker daemon running on this host?

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?

like image 581
Anthony Kong Avatar asked May 20 '17 10:05

Anthony Kong


People also ask

Can not connect docker daemon?

“Cannot connect to the Docker daemon” appears when the Docker CLI is unable to communicate with a Docker daemon instance using your current configuration. This is often because the Docker daemon service has been stopped or disabled. You could also be trying to connect to a remote Docker host that's gone offline.

Where is docker daemon on Mac?

On MacOS go to the whale in the taskbar > Preferences > Daemon > Advanced, or locate ~/. docker/daemon. json. You can also start the Docker daemon manually and configure it using flags.


1 Answers

On a supported Mac, run:

brew install --cask docker 

Then launch the Docker app. Click next. It will ask for privileged access. Confirm. A whale icon should appear in the top bar. Click it and wait for "Docker is running" to appear.

You should be able to run docker commands now:

docker ps 

Because docker is a system-level package, you cannot install it using brew install, and must use --cask instead.

Note: This solution only works for Macs whose CPUs support virtualization, which may not include old Macs.

Edit 2022 - It was brought up in the comments section that there has been a licensing change for Docker Desktop. Please consider alternatives below, and check the comments for details.

like image 67
friederbluemle Avatar answered Oct 21 '22 14:10

friederbluemle