docker / kitematic

Visual Docker Container Management on Mac & Windows
https://kitematic.com
Apache License 2.0
12.23k stars 1.41k forks source link

Cannot connect to the Docker daemon. Is the docker daemon running on this host? #1182

Closed risham33 closed 8 years ago

risham33 commented 9 years ago

I am running the command below which is causing me docker daemon connection error. docker build --no-cache -t market:v1 .

My version: Client: Version: 1.9.0 API version: 1.21 Go version: go1.4.3 Git commit: 76d6bc9 Built: Tue Nov 3 19:20:09 UTC 2015 OS/Arch: darwin/amd64

Server: Version: 1.9.0 API version: 1.21 Go version: go1.4.3 Git commit: 76d6bc9 Built: Tue Nov 3 19:20:09 UTC 2015 OS/Arch: linux/amd64

FrenchBen commented 9 years ago

@risham33 Before running the docker command (unless you used the Docker CLI) you need to make sure that your environment is setup properly, by doing: eval "$(docker-machine env default)"

bradjcox commented 8 years ago

Dead in the water trying to get started on Mac El Capitan. First time using docker.

imac:docker Brad$ eval "$(docker-machine env default)" imac:docker Brad$ ./build-xframes-docker Password: Cannot connect to the Docker daemon. Is the docker daemon running on this host?

imac:docker Brad$ docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world

b901d36b6f2f: Pull complete 0a6ba66e537a: Pull complete Digest: sha256:8be990ef2aeb16dbcb9271ddfe2610fa6658d13f6dfb8bc72074cc1ca36966a7 Status: Downloaded newer image for hello-world:latest

Hello from Docker. This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:

  1. The Docker client contacted the Docker daemon.
  2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
  3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading.
  4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal.

To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker Hub account: https://hub.docker.com

For more examples and ideas, visit: https://docs.docker.com/userguide/

imac:docker Brad$ docker version Client: Version: 1.9.0 API version: 1.21 Go version: go1.4.3 Git commit: 76d6bc9 Built: Tue Nov 3 19:20:09 UTC 2015 OS/Arch: darwin/amd64

Server: Version: 1.9.0 API version: 1.21 Go version: go1.4.3 Git commit: 76d6bc9 Built: Tue Nov 3 19:20:09 UTC 2015 OS/Arch: linux/amd64

imac:docker Brad$ docker info Containers: 8 Images: 230 Server Version: 1.9.0 Storage Driver: aufs Root Dir: /mnt/sda1/var/lib/docker/aufs Backing Filesystem: extfs Dirs: 246 Dirperm1 Supported: true Execution Driver: native-0.2 Logging Driver: json-file Kernel Version: 4.1.12-boot2docker Operating System: Boot2Docker 1.9.0 (TCL 6.4); master : 16e4a2a - Tue Nov 3 19:49:22 UTC 2015 CPUs: 1 Total Memory: 1.956 GiB Name: default ID: CXRG:SPWL:CAZE:X4IK:7N7Y:7VKO:KUAO:PRF7:IJ3K:W7J3:33CJ:C2ZB Debug mode (server): true File Descriptors: 37 Goroutines: 86 System Time: 2015-11-14T19:35:15.364031298Z EventsListeners: 0 Init SHA1: Init Path: /usr/local/bin/docker Docker Root Dir: /mnt/sda1/var/lib/docker Labels: provider=virtualbox imac:docker Brad$

imac:docker Brad$ docker-machine env default export DOCKER_TLS_VERIFY="1" export DOCKER_HOST="tcp://192.168.99.100:2376" export DOCKER_CERT_PATH="/Users/Brad/.docker/machine/machines/default" export DOCKER_MACHINE_NAME="default"

Run this command to configure your shell: eval "$(docker-machine env default)"

FrenchBen commented 8 years ago

@bradjcox Looks like this is working correctly when you're using the docker commands. It seems that you're having issues when using the build-xframes-docker - Perhaps you should ask the maintainer of the script to check/verify that it works correctly on your setup.

FrenchBen commented 8 years ago

Closing this for lack of activity in the past 15days.

henriale commented 8 years ago

I've got the same problem. Any solution?

FrenchBen commented 8 years ago

@Alexandreh I would make sure that you have a clean install, then check that your env variables get set properly. What does docker-machine env default return?

henriale commented 8 years ago

this command returns:

export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="/Users/alexandrearaujo/.docker/machine/machines/default"
export DOCKER_MACHINE_NAME="default"
# Run this command to configure your shell: 
# eval "$(docker-machine env default)"

and if I run eval "$(docker-machine env default)" it outputs anything.

I'm not familiar with Docker yet, but I've followed the tutorials step by step

FrenchBen commented 8 years ago

once you've copied and pasted the eval ... then you should be able to do docker ps

bcferrycoder commented 8 years ago

On El Capitan (OS X 10.11.2) I follow the steps outlined here: https://docs.docker.com/engine/installation/mac/

My environment is as follows:

  $ env | grep DOCKER
  DOCKER_HOST=tcp://192.168.99.100:2376
  DOCKER_MACHINE_NAME=default
  DOCKER_TLS_VERIFY=1
  DOCKER_CERT_PATH=/Users/bc/.docker/machine/machines/default

I'm able to access 192.168.99.100 on port 2376 via nc and telnet.

But, "docker ps" fails:

   $ docker ps
   Cannot connect to the Docker daemon. Is the docker daemon running on this host?

Note that Kitematic is working fine. It's just the docker command-line that's failing. Anyone else been successful with docker-machine on El Capitan?

FrenchBen commented 8 years ago

@bcferrycoder what's the output of: docker-machine env default ?

bcferrycoder commented 8 years ago

@FrenchBen here you go:

$ docker-machine env default
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="/Users/bc/.docker/machine/machines/default"
export DOCKER_MACHINE_NAME="default"
# Run this command to configure your shell: 
# eval "$(docker-machine env default)"

Then I run the eval, and docker still fails:

$ eval "$(docker-machine env default)"
$ docker ps
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
FrenchBen commented 8 years ago

can you ping the host? ping 192.168.99.100 and provide the output of: docker-machine ssh default docker ps

bcferrycoder commented 8 years ago

Yes I can ping the host:

$ ping 192.168.99.100
PING 192.168.99.100 (192.168.99.100): 56 data bytes
64 bytes from 192.168.99.100: icmp_seq=0 ttl=64 time=0.387 ms
64 bytes from 192.168.99.100: icmp_seq=1 ttl=64 time=0.261 ms

And here's the output from the ssh command:

$ docker-machine ssh default docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

FWIW this is on VirtualBox 5.0.10, on Mac OS X v10.11.12, docker version 1.9.1.

FrenchBen commented 8 years ago

One more try:

$ eval "$(docker-machine env -u)"
$ eval "$(docker-machine env default)"
$ docker ps
bcferrycoder commented 8 years ago

Sadly:

$ eval "$(docker-machine env -u)"
$ eval "$(docker-machine env default)"
$ docker ps
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

I experience this same behavior on Yosemite and El Capitan. I'm curious if anyone's been successful running docker via docker-machine on Mac? Thanks.

FrenchBen commented 8 years ago

I've never seen such issues tbh - Everything works. docker-machine does work, since you're getting the info above without issues

It's possible that you have some odd terminal setting that is preventing the connection. If you open a 'clean' terminal, what is your env like?

bcferrycoder commented 8 years ago

Interesting. If I invoke docker like so:

docker --tlsverify --tlscacert=ca.pem --tlscert=cert.pem --tlskey=key.pem -H tcp://192.168.99.100:2376 ps

Then it works fine.

So it seems the docker client isn't picking up the various docker environment settings as set by eval "$(docker-machine env default)"

I did try a fresh shell with absolutely no environment whatsoever other than that set by docker-machine.

$ env
DOCKER_HOST=tcp://192.168.99.100:2376
DOCKER_MACHINE_NAME=default
DOCKER_TLS_VERIFY=1
DOCKER_CERT_PATH=.docker/machine/machines/default
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
_=/usr/bin/env

$ docker ps
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

Baffling...

FrenchBen commented 8 years ago

that is very strange. for the first command, you can also do: docker $(docker-machine config default) ps

The one thing that is odd, is your cert path - it's actually not complete. eg mine is:

env | grep -i docker
DOCKER_TLS_VERIFY=1
DOCKER_HOST=tcp://192.168.99.100:2376
DOCKER_CERT_PATH=/Users/frenchben/.docker/machine/machines/default
DOCKER_MACHINE_NAME=default

What is the version reported by docker-machine version Also: which docker-machine which docker

bcferrycoder commented 8 years ago

Interesting. This works:

$ docker $(docker-machine config default) ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

And this doesn't:

$ eval "$(docker-machine env default)"
$ docker ps
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
bcferrycoder commented 8 years ago

In response to your other queries:

$ which docker-machine
/usr/local/bin/docker-machine
$ docker-machine version
docker-machine version 0.5.3, build 4d39a66
$ which docker
/usr/local/bin/docker
$ docker version
Password:
Client:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.3
 Git commit:   a34a1d5
 Built:        Fri Nov 20 17:56:04 UTC 2015
 OS/Arch:      darwin/amd64
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

PS: @FrenchBen ongoing thanks to you helping me chase this down!

bcferrycoder commented 8 years ago

Oh no. I just figured it out. I had a legacy alias docker="sudo docker" back from the old days (like 2013) before docker consulted /etc/groups to bypass sudo requirement to run docker.

I removed the alias and voila, everything works. @FrenchBen I owe you a beer! All is working now. My apologies for the goose chase.

FrenchBen commented 8 years ago

@bcferrycoder Glad you found out the root cause - Figured something like that was going on.

I'll take a :beer: for the on-going effort :D

lfilho commented 8 years ago

I'm on OSX El Capitan, with last version of docker (1.9.1), installed via homebrew (I previously tried with the official download too, same problem). After run the eval command I'm able to issue some commands but after a while it seems to just disconnect and I get the Cannot connect to the Docker daemon. Is the docker daemon running on this host? message.

I'm also running last version of docker-machine (0.5.4) and virtualbox (5.0.10).

Running zsh + iTerm. That happened with both docker quick start terminal and also starting the commands by hand in a pre-existing terminal window.

I also check for "sudo docker" alias but I have no such alias in my system.

FrenchBen commented 8 years ago

@lfilho Please keep the issue isolated to 1 place - You've already commented on a closed issue and doing the same here is not helping anyone

ShashankaNataraj commented 8 years ago

Facing the same issue on OSX El Captain.

FrenchBen commented 8 years ago

@ShashankaNataraj Did you try the above debugging steps?

FrenchBen commented 8 years ago

@realisation then the VM didn't get created

FrenchBen commented 8 years ago

@realisation I would start Kitematic as it will create the VM for you.

danpe commented 8 years ago

Same here.. Cannot connect to the Docker daemon. Is the docker daemon running on this host?

FrenchBen commented 8 years ago

@danpe did you run the above command? eval "$(docker-machine env default)"

deepakmohanakrishnan07 commented 8 years ago

eval "$(docker-machine env default)" works on my OS X Yosemite.

mko commented 8 years ago

For individuals who run into this issue in the future, it should be noted that the Cannot connect to the Docker daemon. Is the docker daemon running on this host? error occurs reproducibly when using sudo docker to execute commands. Make sure you're not using sudo. Admittedly, the error handling here should be better (more like that of Homebrew, which tells the user that sudo is not meant to be used when they authenticate to execute a command).

ShashankaNataraj commented 8 years ago

Im trying to stick eval "$(docker-machine env default)" in a .sh file and run it everytime my terminal starts (OSX El Captain). Problem is this doesnt seem to have any effect and I get the same error until I type / paste this in manually and execute this command. Any pointers?

filipkokorevs commented 8 years ago

Have the same problem: I've installed a fresh version of docker using Docker Toolbox (Had never any installations of docker before). And now when I starting new shell I'm getting:

$ docker ps
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

and when I do:

$ eval $(docker-machine env default)
docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

Docker works fine.

Seems I need to run eval command everytime I open new console session.

$ docker version
Client:
 Version:      1.10.3
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   20f81dd
 Built:        Thu Mar 10 21:49:11 2016
 OS/Arch:      darwin/amd64

Server:
 Version:      1.10.3
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   20f81dd
 Built:        Thu Mar 10 21:49:11 2016
 OS/Arch:      linux/amd64

Using Mac OS X El Captain (10.11.3)

ShashankaNataraj commented 8 years ago

@filipskokorevs It really is a bother to run that command everytime a terminal session starts...

filipkokorevs commented 8 years ago

@ShashankaNataraj Yep, I guess for now you could add this line in your ~/.bashrc file. But in general the issue should be ofc solved by docker.

petergdoyle commented 8 years ago

I am yet to be convinced of the benefit of using Docker-Machine(/Boot2Docker) for OS X and this is one of those very issues. I would rather (might as well) create my own Linux VM with Virtualbox and Vagrant and start that (or just keep it running all the time) and have a real linux-docker environment as Mac OS X shell brings along its own set of inconveniences if you plan on running shell scripts and utilities that are to be compatible with both OS X and Linux (at least the distros I use) - but that is a different discussion but for references some of the differences are outlined here. I would rather not have to have two versions of my automation and execution scripts. Why OS X doesn't just support CGROUPS natively is another discussion as well; then this kluge (Docker-Machine/Boot2Docker) would be unnecessary. If anyone is interested you can take a look at how to roll-your-own docker machine with Vagrant and VirtualBox - Virtualbox already got installed anyway if you got this far. You don't have to pull my Vagrant CentOS image you can pull or create your own Vagrant Box - setup

prashathsenthil commented 8 years ago

Could someone please post what is the resolution for this error "Cannot connect to the Docker daemon. Is the docker daemon running on this host?"...

FrenchBen commented 8 years ago

@prashathsenthil issue the following in a terminal: docker-machine env default

loonydevil commented 8 years ago

is there a way to fix it for boot2docker? I'm tied to use this one...

FrenchBen commented 8 years ago

@loonydevil you mean that you do not have docker-machine? the original boot2docker came with an app click, from which you issues all of your commands. Essentially you were in the VM to start with.

loonydevil commented 8 years ago

Ok, as far as I understand, there are boot2docker, which is the older way to run docker on OS X, and docker-machine, the newer one. I have to use boot2docker due to some policies and everything was working until I deleted boot2docker-vm in Virtual Box. After that I tried to do boot2docker init to recreate it, tried full uninstall/install of boot2docker - still the same result, 'Cannot connect to the Docker daemon...' on every docker command.

jimmycann commented 8 years ago

For anyone who has a similar problem with docker on OSX, I was able to find the solution here: http://blog.petehouston.com/2016/03/05/run-docker-properly-on-mac-os-x/

To paraphrase

docker-machine create --driver virtualbox default docker-machine env default eval $(docker-machine env default)

Was then able to run Docker commands in OSX

FrenchBen commented 8 years ago

@yjimk thanks for the link - These steps are also highlighted in our docs: https://docs.docker.com/machine/get-started/#/create-a-machine

aseemxandr commented 4 years ago

My code in Atom was not even using docker. I restarted Atom and then it gave me 'autopep8' not found error. Then I did pip3 install --upgrade autopep8and it worked.