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

Created on 13 Oct 2015  Â·  31Comments  Â·  Source: docker/compose

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.

kinquestion

Most helpful comment

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)"

All 31 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 getting the same error, but I don't want to use the default machine but rather another machine created with the amazonec2 driver, is it possible?

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

ah thanks, I didn't know about DOCKER_HOST!!
Why not adding a command line parameter that would override this value??

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 (TM) :smile:

Yes it works. But why eval $(docker-machine env default) suddenly. It was working fine before

Yeah, I'm not sure either. Was working for me earlier as well.

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

Eval "$(docker-machine env default)" worked, thanks!

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?

@shankiesan alias eval_evil_docker="eval $(docker-machine env default)"

Hah yes I guess that wouldwork @michahell . Still have to do something before every time you use docker. Not ideal, but not bad!

@shankiesan The only other option I can see is to export the variables produced from docker-machine env default in .bash_profile. Yes the IP could theoretically change, but in reality this is far less likely to occur than the delay in opening a new shell on a daily basis and if it does you can always update :-)

That's a good idea @lewistaylor . I tried that before it didn't work, but it has this time so it must have been operator error. Nice one, that's a great suggestion :+1:

@shankiesan @lewistaylor wow, can't understand I didn't come up with that. even better solution :+1:

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

Sometimes I have the same issue BUT it comes up ONLY when I close my macbook. If I restart the system it may start fine, may not. If not I restart again and it's usually working. My guess is that probably the problem in the IP/ports, only guess, cause if I restart my laptop with unclosed programs (like PHPStorm) it usually won't work. If I close all the running programs and restart it, it's working.

+1

@lewistaylor @shankiesan @michahell How do you export the variables from docker-machine env default in .bash_profile? I'm not so good with bash, so I'd appreciate help on implementing this fix.

Drop docker-machine/dinghy/boot2docker and use docker for mac, it's set to
become the official runtime
On 3 Jun 2016 08:03, "nwshane" [email protected] wrote:

@lewistaylor https://github.com/lewistaylor @shankiesan
https://github.com/shankiesan @michahell https://github.com/michahell
How do you export the variables from docker-machine env default in
.bash_profile? I'm not so good with bash, so I'd appreciate help on
implementing this fix.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/docker/compose/issues/2180#issuecomment-223505966,
or mute the thread
https://github.com/notifications/unsubscribe/AAeWNmFAR8k9Aszni-FDcGrkfK4dVEAeks5qH9GugaJpZM4GN-hv
.

@nwshane Just edit .bash_profile in your favourite text editor. For instance:

nano ~/.bash_profile and add the lines that you got from docker-machine env default. Then you have to source that file – you can do this by either opening and closing your terminal session, or better, source ~/.bash_profile

That should do it.

@shankiesan Great, thanks! That did the trick. I was confusing myself by thinking that I had to run docker-machine env default and get the variables from there—but of course that's what eval "$(docker-machine env default)" does.

$ wordpress-compose eval $(docker-machine env wordpress)
$ wordpress-compose docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
443c7386f4ef wordpress "/entrypoint.sh apach" 7 minutes ago Up 7 minutes 0.0.0.0:80->80/tcp wordpress_app
a790fdc3ca70 mysql "docker-entrypoint.sh" 14 minutes ago Up 14 minutes 0.0.0.0:3360->3306/tcp wordpress_db
$ wordpress-compose docker-compose up
ERROR: Couldn't connect to Docker daemon - you might need to run docker-machine start default.`

$ wordpress-compose docker-compose --version
docker-compose version 1.8.0-rc1, build 9bf6bc6

$ wordpress-compose docker --version
Docker version 1.12.0-rc2, build 906eacd, experimental

Here is my information, everything works fine if I use docker run .......mysql..... and docker run ....link....wordpress, and I can access the blog in browser. When I want to try docker-compose, It doesn't work. I have deleted the default machine, Now wordpress is in use.

Could help me find out what is wrong?

i am having the same issue
but i am not using docker-machine only docker-compose
any idea ??

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

Had the same problem with one specific service in docker-compose.

Was a permissions issue... the files to be uploaded to docker were not owned by the current user.

Same as @Rots here =/

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

"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 !

SSL error: EOF occurred in violation of protocol (_ssl.c:777)

Was this page helpful?
0 / 5 - 0 ratings