moby: Failed to connect to the Docker daemon

Description of problem:

After install docker by running curl -sSL https://test.docker.com/ | sh , and DOCKER_HOST environment variable is not set in my shell, run docker cmd, but return : $ docker ps Cannot connect to the Docker daemon. Is the docker daemon running on this host? $ service docker status docker start/running, process 28966

docker version :

Client:
 Version:      1.9.0-rc5
 API version:  1.21
 Go version:   go1.4.2
 Git commit:   9318004
 Built:        Tue Nov  3 05:59:27 UTC 2015
 OS/Arch:      linux/amd64
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

docker info :

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

uname -a :

Linux docker 3.13.0-43-generic #72-Ubuntu SMP Mon Dec 8 19:35:06 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

Environment details (AWS, VirtualBox, physical, etc.):OpenStack Cloud instance

Actual Results: docker daemon cannot work

Expected Results: docker daemon can work Ok

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 45 (5 by maintainers)

Most upvoted comments

Could you please try running

sudo su -
service docker start
docker images

See if that works. And if it does, please add your user to the docker user group like this =>

sudo usermod -aG docker <username>

Edit: You might have to log out and than back in again for it to take effect.

@Skarlso , I did “sudo usermod -aG docker ubuntu” , but not log out and back in to take effect. Thanks, 😄

For ubuntu 14.04 on virtual box vm with docker installation

sudo groupadd docker sudo gpasswd -a ${USER} docker sudo service docker restart Now, restart the OS. This solution is well explained here https://jee-appy.blogspot.com/2016/02/installing-docker-in-virtual-box.html

On Fedora 22

Installing Docker: $> curl -fsSL https://get.docker.com/ | sh

After installing Docker:

A user needs to be added to the docker group. $> sudo usermod -aG docker <username>

The docker daemon needs to be started $> sudo service docker start

You can set the daemon to start at boot $> sudo chkconfig docker on

You can verify the docker service is running $> service docker status

And one last final check $> docker run hello-world

Solved by manually starting the daemon. For some reason, the service is not actually starting it.

ran docker daemon & and now it’s working fine. will have to investigate further to see why the service is not fully starting it.

On my latest Mac OSX Sierra, I also got the error, after I install Docker Toolbox, when I run docker on my terminal:

git:(master) ✗ docker version
Client:
 Version:      1.12.2
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   bb80604
 Built:        Tue Oct 11 17:00:50 2016
 OS/Arch:      darwin/amd64
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

I’m having the same problem but neither of the solutions provided worked.

service docker status

Redirecting to /bin/systemctl status  docker.service

● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since Wed 2015-12-16 18:19:56 EST; 17h ago
     Docs: https://docs.docker.com
 Main PID: 5181 (docker)
   Memory: 2.3M
   CGroup: /system.slice/docker.service
           └─5181 /usr/bin/docker daemon -H fd://

When I try to execute other commands, it shows “cannot connect to the docker daemon”

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

Has any one tried other troubleshooting? I’m running redhat/softlayer.

BTW, It was running hello-world fine, but now after following the above troubleshooting, it’s showing the error when I try hello-world as well.

I got same issue on Cent OS 7 which I installed docker by yum. I tried all @xecronix mentioned here but still can’t fix it.

At last I found I should run docker after sudo. The hint doesn’t mean docker daemon isn’t running…

Hah, I couldn’t count on one hand how many times that happened to me as well. 😄 👍

Just follow below steps to resolve the issue.

$:sudo groupadd docker $:sudo gpasswd -a ${USER} docker $:sudo service docker restart $:newgrp docker

fully restart the os, not just logging out and back in. was the solution for me.

To anyone who stumbles across this issue in the future.

I just spent a bit of time debugging this issue in a few of my servers. I now realize ssh ControlPersist multiplexing makes the whole ‘log out log back in’ thing not work the way you think it does. It makes sense why this happens, I just never thought about it happening like this before.

To fix this

$ ssh -O check -S ~/.ssh/mux-user@server.com server.com
Master running (pid=14920)
$ ssh -O stop -S ~/.ssh/mux-user@server.com server.com
Stop listening request sent.

Then log back into your server.

@johshoff docker 1.13 will give a more informative error message if the client fails to connect due to permissions error; see this pull request; https://github.com/docker/docker/pull/26797

On the latest Arch Linux, the only way I can get docker to work is to

sudo systemctl stop docker sudo docker daemon &

Then it works appropriately.

After it is started by systemctl, I see this in the process list:

root 1933 0.0 0.1 360524 11748 ? Ssl 08:47 0:00 docker-containerd -l /var/run/docker/libcontainerd/docker-containerd.sock --runtime docker-runc

When I run it manually, I see:

root      2307  1.7  0.5 604268 34520 pts/0    Sl   08:56   0:00 docker daemon
root      2313  0.2  0.2 221256 12112 ?        Ssl  08:56   0:00 docker-containerd -l /var/run/docker/libcontainerd/docker-containerd.sock --runtime docker-runc

I had the same problem on Arch Linux (Docker package version: 1:17.03.1-1). I modified this on /usr/lib/systemd/system/docker.service and I got it working fine after that.

#ExecStart=/usr/bin/dockerd -H fd://
ExecStart=/usr/bin/dockerd

Based on the number of people giving a thumbs up to @Skarlso’s comment about

sudo usermod -aG docker <username>

maybe there should be check for that so you could say:

You need to be in the ‘docker’ group

instead of the misleading advice

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

The use group changes doesn’t apply immediately when a user is added in a group (the user need to log off and log on again for the changes to apply), but it is better to just restart the OS.

On ubuntu 14.04 for me workaround is not simply run docker (not service, but client) as sudo. Before run “docker run --rm busybox true”, for example, move to sudo bash by typing “sudo su”. In sudo bash docker is working fine. Apparently, adding user to docker group will have a similar effect and in this case run bash as sudo is not necessary.

Yes, I used the official packman -S docker route.

After a fresh reboot:

● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabl
   Active: active (running) since Tue 2016-05-24 09:28:34 CDT; 12s ago
     Docs: https://docs.docker.com
 Main PID: 7302 (docker)
    Tasks: 19 (limit: 512)
   Memory: 15.4M
      CPU: 134ms
   CGroup: /system.slice/docker.service
           ├─7302 /usr/bin/docker daemon -H fd://
           └─7308 docker-containerd -l /var/run/docker/libcontainerd/docker-containerd.so

May 24 09:28:34 libran docker[7302]: time="2016-05-24T09:28:34.277017655-05:00" level=info msg="[graphdriver] using prior storage driver \"btrfs\""
May 24 09:28:34 libran docker[7302]: time="2016-05-24T09:28:34.289658653-05:00" level=info msg="Graph migration to content-addressability took 0.00 seconds"
May 24 09:28:34 libran docker[7302]: time="2016-05-24T09:28:34.295186622-05:00" level=info msg="Firewalld running: false"
May 24 09:28:34 libran docker[7302]: time="2016-05-24T09:28:34.341449086-05:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address"
May 24 09:28:34 libran docker[7302]: time="2016-05-24T09:28:34.388887470-05:00" level=info msg="Loading containers: start."
May 24 09:28:34 libran docker[7302]: time="2016-05-24T09:28:34.389074804-05:00" level=info msg="Loading containers: done."
May 24 09:28:34 libran docker[7302]: time="2016-05-24T09:28:34.389156085-05:00" level=info msg="Daemon has completed initialization"
May 24 09:28:34 libran docker[7302]: time="2016-05-24T09:28:34.389239746-05:00" level=info msg="Docker daemon" commit=5604cbe graphdriver=btrfs version=1.11.1
May 24 09:28:34 libran docker[7302]: time="2016-05-24T09:28:34.393658963-05:00" level=info msg="API listen on 0.0.0.0:2375"
May 24 09:28:34 libran systemd[1]: Started Docker Application Container Engine.

journalctl:

-- Subject: Unit docker.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit docker.service has begun starting up.
May 24 09:28:33 libran docker[7302]: time="2016-05-24T09:28:33.271562128-05:00" level=inf
May 24 09:28:34 libran docker[7302]: time="2016-05-24T09:28:34.277017655-05:00" level=inf
May 24 09:28:34 libran docker[7302]: time="2016-05-24T09:28:34.289658653-05:00" level=inf
May 24 09:28:34 libran docker[7302]: time="2016-05-24T09:28:34.295186622-05:00" level=inf
May 24 09:28:34 libran docker[7302]: time="2016-05-24T09:28:34.341449086-05:00" level=inf
May 24 09:28:34 libran docker[7302]: time="2016-05-24T09:28:34.388887470-05:00" level=inf
May 24 09:28:34 libran docker[7302]: time="2016-05-24T09:28:34.389074804-05:00" level=inf
May 24 09:28:34 libran docker[7302]: time="2016-05-24T09:28:34.389156085-05:00" level=inf
May 24 09:28:34 libran docker[7302]: time="2016-05-24T09:28:34.389239746-05:00" level=inf
May 24 09:28:34 libran docker[7302]: time="2016-05-24T09:28:34.393658963-05:00" level=inf
May 24 09:28:34 libran systemd[1]: Started Docker Application Container Engine.
-- Subject: Unit docker.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit docker.service has finished starting up.
-- 
-- The start-up result is done.

Netstat reports: tcp 0 0 0.0.0.0:2375 0.0.0.0:* LISTEN 1/init

But docker keeps saying:

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

So then I run sudo killall -9 docker and then sudo docker daemon &, and the command shows:

WARN[0000] containerd: low RLIMIT_NOFILE changing to max  current=1024 max=4096
INFO[0001] [graphdriver] using prior storage driver "btrfs" 
INFO[0001] Graph migration to content-addressability took 0.00 seconds 
INFO[0001] Firewalld running: false                     
INFO[0001] Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address 
INFO[0001] Loading containers: start.                   

INFO[0001] Loading containers: done.                    
INFO[0001] Daemon has completed initialization          
INFO[0001] Docker daemon                                 commit=5604cbe graphdriver=btrfs version=1.11.1
INFO[0001] API listen on /var/run/docker.sock           

and then it works correctly.

[tsmith@libran ~]$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
namespace/project   latest              74941504eebb        5 weeks ago         1.156 GB

I actually absolutely hate systemd, and I have NO IDEA how to debug or even look at what commands a systemd service actually runs. God! I miss OpenRC so much!

The issue is neatly documented in Docker Documentation.

My environment: VirtualBox

OS: CentOS-7 -x86_64-Minimal

After adding user to the group, execute the following command.

sudo chkconfig docker on

At first, I couldn’t view the server config details on the execution of docker version , and I received the same error “Cannot connect to the Docker daemon. Is the docker daemon running on this host?”

After executing sudo chkconfig docker on , everything works super fine 😃