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)
Could you please try running
See if that works. And if it does, please add your user to the docker user group like this =>
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:
I’m having the same problem but neither of the solutions provided worked.
When I try to execute other commands, it shows “cannot connect to the docker daemon”
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
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:
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.Based on the number of people giving a thumbs up to @Skarlso’s comment about
maybe there should be check for that so you could say:
instead of the misleading advice
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:
journalctl:
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 thensudo docker daemon &
, and the command shows:and then it works correctly.
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 😃