compose: [Mac] docker-compose won't run due to "Couldn't connect to Docker daemon" error

I’m very confused about how docker-compose is supposed to work on my Mac. Here are the steps I took:

  1. Installed Docker Toolbox (Docker version 1.8.2)
  2. Tried to run docker-compose up but got Illegal instruction: 4 error as per #1885
  3. To fix the issue, I installed docker-compose with pip via sudo pip install -U docker-compose
  4. Now when I run docker-compose up I get Couldn't connect to Docker daemon - you might need to runboot2docker up.

Which is very confusing because all the documentation says that boot2docker is deprecated. And trying to install boot2docker isn’t working for me either.

I’m not sure what else to try. Currently have docker-compose v1.4.2 installed.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 6
  • Comments: 31

Commits related to this issue

Most upvoted comments

We recently fixed this error message (the fix will be in the next release).

It should say “you might need to run docker-machine start default”.

If you still can’t connect, and the docker-machine is running, you can configure compose to use the machine with eval "$(docker-machine env default)"

Ok thanks. Looks like my issue is with the Docker VM. It’s giving me all sorts of TLS errors even when running regular docker commands like docker images.

Get http:///var/run/docker.sock/v1.20/images/json: dial unix /var/run/docker.sock: no such file or directory.
* Are you trying to connect to a TLS-enabled daemon without TLS?
* Is your docker daemon up and running?

I’ll take it up with the docker team.

UPDATE

For anyone also having this issue. The solution for me was to:

  • Run the Docker Quickstart Terminal app
  • Run docker-machine restart default
  • Run eval $(docker-machine env default)

Apparently you need to run the eval $(docker-machine env default) every time you run the quick start terminal.

I’d just like to add something for anyone who visits this in the future… I keep having this issue every time I open a new shell, so I added eval $(docker-machine env default) to my ~/.bash_profile. Works a treat. Of course, someone here may tell me that this is a Very Bad Idea ™ 😄

I’m still not totally happy with the solution of adding eval $(docker-machine env default) to ~/.bash_profile (even though I proposed it) as it adds about a 2s delay onto opening a new terminal window. Anyone have any better ideas?

Yes. Compose will use whatever engine is set in the DOCKER_HOST environment variable (which is what gets set by eval $(docker-machine env ....).

eval "$(docker-machine env default)" solves the issue

eval $(docker-machine env default) works for me ! thanks 😃

"Error checking TLS connection: machine does not exist" now getting this issue whenever i try to use docker-machine env default , tried loading from the bash_profile too , need help !

paste the command: eval “$(docker-machine env default)” on your mac terminal

this issue still persist , the only solution is to use

$ eval $(docker-machine env the-vm-name) // which doesnt give any output & without it we get the error
$ docker-compose up