Skip to content
This repository has been archived by the owner on Jun 11, 2021. It is now read-only.

Cannot connect to the Docker daemon. Is 'docker -d' running on this host? #1010

Closed
snakezzl opened this issue Sep 5, 2015 · 51 comments
Closed

Comments

@snakezzl
Copy link

snakezzl commented Sep 5, 2015

When i run docker ps on Mac OS X, it shows "Cannot connect to the Docker daemon. Is 'docker -d' running on this host?".

Here is my docker version when i run docker version:

Client:
 Version:      1.8.1
 API version:  1.20
 Go version:   go1.4.2
 Git commit:   d12ea79
 Built:        Thu Aug 13 02:49:29 UTC 2015
 OS/Arch:      darwin/amd64
Cannot connect to the Docker daemon. Is 'docker -d' running on this host?

And here is my shell env when i run docker-machine env default

DOCKER_CERT_PATH=/Users/dracochou/.docker/machine/machines/default
DOCKER_HOST=tcp://192.168.99.101:2376
DOCKER_TLS_VERIFY=1
DOCKER_MACHINE_NAME=default

Could someone tell me why i can not exec docker ps?

@FrenchBen
Copy link
Contributor

@snakezzl When you run docker-machine env default it doesn't set the actual env variables. At the end of the message you will see something like:

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

Do that and you should then be able to run the docker version command without any issues.

@mchiang0610
Copy link
Contributor

does clicking on Docker CLI from Kitematic work?

Please reopen at reply. Thanks!

@sabat
Copy link

sabat commented Oct 1, 2015

FYI, the Docker CLI does not work on my Mac (Mavericks, 10.9). I have to run the eval listed above in order to get output from "docker info".

@costimuraru
Copy link

Had to manually run the eval "$(docker-machine env default)" on my Mac to be able to run docker commands.

@FrenchBen
Copy link
Contributor

@sabat @costimuraru Can you click on Docker CLI and scroll up the terminal, then paste the output here? (or as a gist)

@ozbillwang
Copy link

Here is my issue, running with docker CLI:

bash-3.2$ docker version
dClient:
 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
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

bash-3.2$ docker-machine ssh default
                        ##         .
                  ## ## ##        ==
               ## ## ## ## ##    ===
           /"""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
           \______ o           __/
             \    \         __/
              \____\_______/
 _                 _   ____     _            _
| |__   ___   ___ | |_|___ \ __| | ___   ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__|   <  __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
Boot2Docker version 1.9.0, build master : 16e4a2a - Tue Nov  3 19:49:22 UTC 2015
Docker version 1.9.0, build 76d6bc9
docker@default:~$ 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:      linux/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
docker@default:~$

@hasanmehmood
Copy link

Hello Everyone!
I am facing the same issue, I have installed docker on Ubuntu 14.04 64 bit. I have did everything to make this error remove but failed.

 hassan@hassan-Inspiron-3420:~$ docker run hello-world
 Cannot connect to the Docker daemon. Is the docker daemon running on this host?

 hassan@hassan-Inspiron-3420:~$ docker version
 Client:
 Version:      1.9.0
 API version:  1.21
 Go version:   go1.4.2
 Git commit:   76d6bc9
 Built:        Tue Nov  3 17:43:42 UTC 2015
 OS/Arch:      linux/amd64
 Cannot connect to the Docker daemon. Is the docker daemon running on this host?

Any help on this issue will be highly appreciated, Thanks.

@bradjcox
Copy link

Same problem here. Quite new to this so really need some help.

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

@v-pendyala
Copy link

$ docker run hello-world
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

If you are getting the above error, first go and check the docker demon is running or not,
$service docker status
if not running start the docker by running,
$service docker start

then try again.

@hasanmehmood
Copy link

@varunnani407

I have started the daemon,

hassan@hassan-Inspiron-3420:~$ sudo /usr/bin/docker daemon
[sudo] password for hassan: 
INFO[0000] [graphdriver] using prior storage driver "aufs" 
INFO[0000] API listen on /var/run/docker.sock           
INFO[0000] Firewalld running: false                     
INFO[0000] Default bridge (docker0) is assigned with an IP address 172.17.0.1/16. Daemon option -                -bip can be used to set a preferred IP address 
INFO[0000] Loading containers: start.                 

INFO[0000] Loading containers: done.                    
INFO[0000] Daemon has completed initialization          
INFO[0000] Docker daemon                                 commit=76d6bc9 execdriver=native-0.2            graphdriver=aufs version=1.9.0

But still getting the same error, when I tried to run the following command on another terminal.

$ docker run hello-world
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

@v-pendyala
Copy link

@hasanmehmood

hope you gone through the installation procedure as per the: http://docs.docker.com/linux/step_one/

i also tried with what you are trying
$sudo /usr/bin/docker daemon
INFO[0000] API listen on /var/run/docker.sock
INFO[0000] [graphdriver] using prior storage driver "aufs"
INFO[0000] Firewalld running: false
INFO[0000] Default bridge (docker0) is assigned with an IP address 172.17.0.1/16. Daemon option --bip can be used to set a preferred IP address
WARN[0000] Your kernel does not support swap memory limit.
INFO[0000] Loading containers: start.
........
INFO[0000] Loading containers: done.
INFO[0000] Daemon has completed initialization
INFO[0000] Docker daemon commit=76d6bc9 execdriver=native-0.2 graphdriver=aufs version=1.9.0
INFO[0008] GET /v1.21/version
INFO[0023] GET /v1.21/images/json

I am able to run properly, if the issue still exists try to reinstall it

@jorgegus100
Copy link

Works great @bradjcox , thanks

@dayelostraco
Copy link

If you'd prefer not to have to run the eval statement mentioned by @FrenchBen and @costimuraru on every terminal session, you could update you bash_profile with the following:

#Docker
eval "$(docker-machine env default)"

Be sure to restart the terminal session or run source for the changes to take effect.

@blackcr0w
Copy link

@dayelostraco Works!

@Arcrammer
Copy link

@dayelostraco Thanks for the suggestion! Hopefully this isn't a problem that's affecting every single Docker user. If that's the case, why is it happening for us?

@ranjib
Copy link

ranjib commented Dec 3, 2015

on ubuntu 15.10 , i have to run docker as root, adding myself in docker group does not allow me to create docker container:

 [master] $ docker version
Client:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.2
 Git commit:   a34a1d5
 Built:        Fri Nov 20 13:20:08 UTC 2015
 OS/Arch:      linux/amd64
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

service status

[master] $ sudo systemctl status docker.service
● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2015-12-02 17:22:16 PST; 11s ago
     Docs: https://docs.docker.com
 Main PID: 19543 (docker)
   Memory: 12.0M
      CPU: 114ms
   CGroup: /system.slice/docker.service
           └─19543 /usr/bin/docker daemon -H fd://

Dec 02 17:22:16 master docker[19543]: time="2015-12-02T17:22:16.648661611-08:00" level=info msg="[graphdriver] using prior storage driver \"aufs\""
Dec 02 17:22:16 master docker[19543]: time="2015-12-02T17:22:16.665141761-08:00" level=info msg="Firewalld running: false"

@FrenchBen
Copy link
Contributor

@ranjib You need to logout then log back in for this to work.

@ranjib
Copy link

ranjib commented Dec 3, 2015

@FrenchBen ah. thats did it. thank you :-)

@npiguet
Copy link

npiguet commented Dec 22, 2015

So I have that problem too, but none of the fixes suggested so far work for me. I'm on Ubuntu 15.10:

npiguet@npi-desktop:~$ docker version
Client:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.2
 Git commit:   a34a1d5
 Built:        Fri Nov 20 13:20:08 UTC 2015
 OS/Arch:      linux/amd64
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
npiguet@npi-desktop:~$ sudo service docker status
● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: active (running) since lun 2015-12-21 19:10:17 CET; 4s ago
     Docs: https://docs.docker.com
 Main PID: 2559 (docker)
   CGroup: /system.slice/docker.service
           └─2559 /usr/bin/docker daemon -H fd://

déc 21 19:10:17 npi-desktop docker[2559]: time="2015-12-21T19:10:17.165558285+01:00" level=info msg="[graphdriver] using prior storage driver \"btrfs\""
déc 21 19:10:17 npi-desktop docker[2559]: time="2015-12-21T19:10:17.166168212+01:00" level=info msg="API listen on /var/run/docker.sock"
déc 21 19:10:17 npi-desktop docker[2559]: time="2015-12-21T19:10:17.168704589+01:00" level=info msg="Firewalld running: false"
déc 21 19:10:17 npi-desktop docker[2559]: time="2015-12-21T19:10:17.251437569+01:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.1/16. Daemon option --bip can be used to set a preferred IP address"
déc 21 19:10:17 npi-desktop docker[2559]: time="2015-12-21T19:10:17.396550051+01:00" level=warning msg="Your kernel does not support swap memory limit."
déc 21 19:10:17 npi-desktop docker[2559]: time="2015-12-21T19:10:17.419627781+01:00" level=info msg="Loading containers: start."
déc 21 19:10:17 npi-desktop docker[2559]: time="2015-12-21T19:10:17.419767858+01:00" level=info msg="Loading containers: done."
déc 21 19:10:17 npi-desktop docker[2559]: time="2015-12-21T19:10:17.419778605+01:00" level=info msg="Daemon has completed initialization"
déc 21 19:10:17 npi-desktop docker[2559]: time="2015-12-21T19:10:17.419787476+01:00" level=info msg="Docker daemon" commit=a34a1d5 execdriver=native-0.2 graphdriver=btrfs version=1.9.1
déc 21 19:10:17 npi-desktop systemd[1]: Started Docker Application Container Engine.

My user is in the docker group:

npiguet@npi-desktop:~$ id
uid=1000(npiguet) gid=1000(npiguet) groups=1000(npiguet),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),113(lpadmin),128(sambashare),999(docker)

The docker-machine command does not exist:

npiguet@npi-desktop:~$ eval "$(docker-machine env default)"
docker-machine: command not found

My environment variables look like that

npiguet@npi-desktop:~$ env | grep DOCKER
DOCKER_HOST=tcp://127.0.0.1:2375

I've already rebooted a few times out of desperation, still no luck. Logging as root, launching the docker deamon manually and running docker version yields the same error.

Any ideas?

@npiguet
Copy link

npiguet commented Dec 22, 2015

A little look at netstat seems to say that the docker daemon is not even listening on port 2375:

npiguet@npi-desktop:~$ sudo netstat -lap | grep docker
unix  2      [ ACC ]     STREAM     LISTENING     27248    2559/docker         /var/lib/docker/network/files/aed0b35396f61a0265548357a78c6c5b00252926a2fe90c30e88e1429446c1ff.sock
unix  2      [ ACC ]     STREAM     LISTENING     25281    1/init              /var/run/docker.sock
unix  3      [ ]         STREAM     CONNECTED     30774    2559/docker         
unix  3      [ ]         STREAM     CONNECTED     28383    2559/docker         
unix  3      [ ]         STREAM     CONNECTED     27291    2559/docker         
unix  2      [ ]         DGRAM                    28377    2559/docker         
unix  3      [ ]         STREAM     CONNECTED     28386    2559/docker   

But somehow, it does seem to be configured correctly:

npiguet@npi-desktop:~$ cat /etc/default/docker 

DOCKER_OPTS="-H tcp://127.0.0.1:2375 --dns 192.168.14.201"

export http_proxy="http://127.0.0.1:3129/"
export https_proxy="http://127.0.0.1:3129/"

But somehow, the launched instance doesn't use those parameters:

npiguet@npi-desktop:/etc/docker/certs.d/docker.io$ ps -eaf | grep docker
root      2559     1  0 déc21 ?       00:00:18 /usr/bin/docker daemon -H fd://

@npiguet
Copy link

npiguet commented Dec 22, 2015

Well apparently, the issue is that the docker package for ubuntu 15.10 is broken out of the box (as in the server is not setup to listen to the port that the client is told to connect to). Actually, the sysvinit configuration is correct, but ubuntu uses systemd and the packaged systemd config for docker just doesn't work.

For other people that have the same problem, a solution for that can be found at: http://nknu.net/how-to-configure-docker-on-ubuntu-15-04/

@FrenchBen
Copy link
Contributor

@npiguet thanks for the feedback and thorough debug of this.

Perhaps you missed the similar comment of the Docker documentation, you'll see that a mention is made about ubuntu 15.04+ and systemd:
https://docs.docker.com/engine/installation/ubuntulinux/#configure-a-dns-server-for-use-by-docker

@lfilho
Copy link

lfilho commented Dec 23, 2015

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.

@Arcrammer
Copy link

@lfilho When you say it disconnects after a while are you referring to the same Terminal session? You'll have to run the eval statement for each session in the proper directory.

@lfilho
Copy link

lfilho commented Dec 23, 2015

Yes, in the same session! I'm issue docker commands normally and out of the blue it stops responding and gives that message... Not sure why. I maybe have opened a different tab on my iTerm to work in something else and then come back to the tab I was working with docker but I don't believe that would be the issue, would it?

I also check for "sudo docker" alias (saw in another thread) but I have no such alias in my system.

@FrenchBen
Copy link
Contributor

@lfilho Do you have any pre-set env vars within your .profile/.zshrc ?
Perhaps you're over-writing the env set by docker-machine?
When you lose connectivity can you do:
env | grep -i docker
ping $(docker-machine ip default)
docker $(docker-machine config default) ps -a
docker $(docker-machine config default) info

Additionally don't use brew to do your updates. use the proper Docker Toolbox installer, to get the tools that work together and have been QA'd as such.

@plusmancn
Copy link

Ref: moby/moby#17645

run

service docker status

show

Main PID: 660 (docker)
   CGroup: /system.slice/docker.service
           └─660 /usr/bin/docker daemon -H fd://

So, if the docker user doesn't belong to the same group as login user, it is not able to access to docker daemon service.

Solution,Add user docker to the same group as login user

sudo usermod -aG docker <username>

IMPORTANT log out and back in to take effect

@FrenchBen
Copy link
Contributor

@plusmancn you're assuming with the above that they started with a new distro and installed docker on it.
When we setup the VM we actually do all of that for you and thus don't need to do the above usermod

@mloayzagahona
Copy link

Are you using the Docker Quickstart Terminal App?

I had the same message but when after I restarted my mac and run this app, it opens a terminal and runs docker, and after this docker is working fine.

@Fakhruddin-Kararawala
Copy link

@npiguet you are right. your workaround also works for me. I am using Ubuntu 15.04.

@FrenchBen
Copy link
Contributor

@Fakhruddin-Kararawala as mentioned above, this was also in the DOCS:
#1010 (comment)

@ZanderZhang
Copy link

Works great on mac @bradjcox , thanks

@TheNotary
Copy link

Make sure your user is assigned to the docker group:

sudo usermod -aG docker "username"
newgrp docker

@Graydyn
Copy link

Graydyn commented Jan 28, 2016

In addition to what TheNotary mentioned, you can just sudo to fix this error if you don't intend to use docker as a non-root user.
sudo docker run hello-world

@click2tman
Copy link

I had similar issues using Ubuntu. Instructions at https://docs.docker.com/engine/installation/ubuntulinux/ solved the problem.

@FrenchBen
Copy link
Contributor

@click2tman Thanks for point to the docs 👍

@MatthewHerbst
Copy link

I just upgraded on OSX 10.10.5 Yosemite. I upgrade to VB5 and upgraded Docker from the latest available Docker Toolbox download. After the upgrade I have the same error as above:

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

When I run the eval code I get:

$ eval "$(docker-machine env default)"
Error checking TLS connection: Error checking and/or regenerating the certs: There was an error validating certificates for host "192.168.99.100:2376": dial tcp 192.168.99.100:2376: getsockopt: connection refused
You can attempt to regenerate them using 'docker-machine regenerate-certs [name]'.
Be advised that this will trigger a Docker daemon restart which will stop running containers.

I tried regenerating the certs but that doesn't fix it.

Any ideas?

Update:
These two issues helped me. Eventually it came down to completely removing Docker from my system, removing the Docker vm and all the host-only networks, restarting, and re-installing Docker.
docker-archive/toolbox#346
docker/machine#2136

@luhuisicnu
Copy link

My os is Ubuntu 14.04
I according to https://docs.docker.com/linux/step_one/ but when I type command:
$ docker run hello-world
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
so I come here to find answer.
At last,I started the service docker,and fix this question
$ sudo service docker start
$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
03f4658f8b78: Pull complete
...

@r01010010
Copy link

I was having this issue but restarting the docker-machine vm at virtualbox (named default) solved it

@TamimiGitHub
Copy link

I see that the resolution to the docker issue has been targeted to OSX and Ubuntu 15.0>
However no discussion was brought about to Ubuntu 14.04. Anyone using Ubuntu 14 and faced the issue of "Cannot connect to the Docker daemon. Is the docker daemon running on this host?"

I have the deamon running on another terminal (sudo docker -d) and this is the outcome of this command
_

API listen on /var/run/docker.sock
[graphdriver] using prior storage driver "aufs"
Firewalld running: false
Default bridge (docker0) is assigned with an IP address 172.17.0.1/16. Daemon option --bip can be used to set a preferred IP address
WARN[0000] Your kernel does not support swap memory limit.
Loading containers: start.

Loading containers: done.
Daemon has completed initialization
Docker daemon commit=a34a1d5 execdriver=native-0.2 graphdriver=aufs version=1.9.1
_

@FrenchBen
Copy link
Contributor

@TamimiGitHub Did you read the docs about having your user added to the proper docker group?
https://docs.docker.com/engine/installation/linux/ubuntulinux/#create-a-docker-group

@TamimiGitHub
Copy link

@FrenchBen Yea this worked after tying to add it, thanks.

@bishoyh
Copy link

bishoyh commented Mar 16, 2016

Had the same problem on Ubuntu 14.04 , it was solved by running the make using sudo
sudo make
or sudo docker run hello-world

@charanrajtc
Copy link

Solved the problem by binding the docker demon to local host
$ sudo nano /etc/default/docker

add Below line

DOCKER_OPTS="--ip 127.0.0.1"

$sudo service docker restart

@MatthewHerbst
Copy link

@charanrajtc I could imagine that breaking lots of other things that assume localhost to actually be the localhost.

@nguyennb9
Copy link

You have to start docker service first:
sudo service docker start
Let try again with sudo
sudo docker run hello-world

@seantcanavan
Copy link

The eval statement does not work for me. It returns:

~ $eval "$(docker-machine env default)"
Host does not exist: "default"

And OSX does not have a 'service' command:

~ $ sudo service docker start
sudo: service: command not found

Completely out of ideas.

@MatthewHerbst
Copy link

@seantcanavan when you setup your docker machine you likely named it something other than default. If you remember what, replace default with that name.

@dc0d
Copy link

dc0d commented Apr 7, 2016

Same problem on Ubuntu 14.04:

user@machine:~/docker-lab-path$ sudo service docker start
start: Job is already running: docker
user@machine:~/docker-lab-path$ docker run hello_world
docker: Cannot connect to the Docker daemon. Is the docker daemon running on this host?.
See 'docker run --help'.
user@machine:~/docker-lab-path$ sudo service docker restart
docker stop/waiting
docker start/running, process 4863
user@machine:~/docker-lab-path$ docker run hello_world
docker: Cannot connect to the Docker daemon. Is the docker daemon running on this host?.
See 'docker run --help'.
user@machine:~/docker-lab-path$ 

@dc0d
Copy link

dc0d commented Apr 7, 2016

My problem solved using sudo usermod -aG docker <user> (provided here).

@FrenchBen
Copy link
Contributor

Locking this as the docs explain specifically what needs to be done.

@docker docker locked and limited conversation to collaborators Apr 9, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests