Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker command can't connect to Docker daemon

People also ask

Can not connect Docker daemon?

“Cannot connect to the Docker daemon” appears when the Docker CLI is unable to communicate with a Docker daemon instance using your current configuration. This is often because the Docker daemon service has been stopped or disabled. You could also be trying to connect to a remote Docker host that's gone offline.

How do I fix Docker got permission denied while trying to connect to the Docker daemon socket?

Fix 1: Run all the docker commands with sudo If you have sudo access on your system, you may run each docker command with sudo and you won't see this 'Got permission denied while trying to connect to the Docker daemon socket' anymore.

How do I access Docker daemon?

On MacOS go to the whale in the taskbar > Preferences > Daemon > Advanced. You can also start the Docker daemon manually and configure it using flags. This can be useful for troubleshooting problems. Many specific configuration options are discussed throughout the Docker documentation.


You need to add your current user to the docker group as follows:

sudo usermod -aG docker $(whoami)

then logout & login again into the system or restart the system. test by docker version

for further info how to install docker-engine follow docker documentation


Add the user to the docker group

  • Add the docker group if it doesn't already exist:

    sudo groupadd docker

  • Add the connected user "${USER}" to the docker group:

    sudo gpasswd -a ${USER} docker

  • Restart the Docker daemon:

    sudo service docker restart

  • Either do a newgrp docker or log out/in to activate the changes to groups.


Usually, the following command does the trick:

sudo service docker restart

This, instead of docker start for the cases where Docker seems to already be running.

If that works then, as suggested and in another answer and on this GitHub issue, if you haven't added yourself in the docker group do it by running:

sudo usermod -aG docker <your-username> 

And you're most likely good to go.


As for anybody else bumping into this, in some OS's docker doesn't start right after you install it and, as a result, the same can't connect to daemon message appears. In this case you can first verify that Docker is indeed not running by checking the status of your docker service by executing:

sudo service docker status

If the output looks something like: docker stop/waiting instead of docker start/running, process 15378 then it obviously means Docker is not active. In this case make sure you start it with:

sudo service docker start

And, as before, you'll most likely be good to go.


note to self: I get the error from the question's title when I forget to run docker command with sudo:

sudo docker run ...

[Ubuntu 15.10]