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?
I had the same problem. Docker running but couldn't access it through CLI.
For me the problem was solved by executing "Docker Quickstart Terminal.app". This is located in the "/Applications/Docker/" folder. As long as I work in this instance of the Terminal app Docker works perfectly. If a second window is needed I have to run the "Quickstart" app once more.
I have a Docker for Mac installation. Therefore I am not sure if my solution is valid for a Homebrew installation.
The "Docker Quickstart Terminal" app seems to be essentially some applescripts to launch the terminal app and a bash start script that initialise all the necessary environment variables.
Hope this helps someone else !
i simply had to run spotlight search and execute the Docker application under /Applications folder which
brew cask install
created. Once this was run it asked to complete installation. I was then able to rundocker ps
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.Try this to create default.
I first tried docker and docker-compose via homebrew, but it had the problem listed here. I had to install docker's official install from https://docs.docker.com/docker-for-mac/install/ and then everything worked as expected.
On macOS the
docker
binary is only a client and you cannot use it to run the docker daemon, because Docker daemon uses Linux-specific kernel features, therefore you can’t run Docker natively in OS X. So you have to installdocker-machine
in order to create VM and attach to it.Install
docker-machine
on macOSIf you don't have
docker-machine
command yet, install it by using one of the following methods:brew install docker-machine docker
.manually:
See: Get started with Docker for Mac.
Configure
docker-machine
on macOSCreate a
default
machine (if you don't have one, see:docker-machine ls
):Then set-up the environment for the Docker client:
Then double-check by listing containers:
See: Get started with Docker Machine and a local VM.
Related: