Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

docker

ubuntu

I have installed docker on ubuntu 14.04, it told me installed successfully. Then I entered sudo docker version, it returned

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

I entered sudo service docker status, I got

docker start/running, process 8063 

I tried sudo docker images and sudo docker info, I got the same reply:

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

I do not know why it returned this, I tried to pull ubuntu using sudo docker pull ubuntu, and got

Using default tag: latest Cannot connect to the Docker daemon. Is the docker daemon running on this host? 

Please tell me how can I solve this problem, how can I pull and run docker image. And is docker -d the same as docker deamon?

like image 358
thiiiiiking Avatar asked Dec 26 '15 11:12

thiiiiiking


People also ask

Is Docker daemon running on this host?

Check what's displayed under “Active.” If you see active (running) in green, the Docker daemon is running and your containers should be up. An active state of inactive indicates the service has stopped. Try to bring it up by running sudo systemctl start docker .

Why is my Docker daemon not running?

Conclusion. The Docker daemon is a backend service of Docker that controls the Docker container. To resolve the Docker daemon is not running error, you first need to verify if the service of Docker Desktop is running or not. If the service is running then update the WSL package.


2 Answers

You need to add your current user to docker group like following:

sudo usermod -aG docker <your username> 

Also, you can use USER environment variable like:

sudo usermod -aG docker $USER 

Then restart the system. As the docker documentation says:

The docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the user root and other users can access it with sudo. For this reason, docker daemon always runs as the root user.

To avoid having to use sudo when you use the docker command, create a Unix group called docker and add users to it. When the docker daemon starts, it makes the ownership of the Unix socket read/writable by the docker group.

like image 115
Ali Dehghani Avatar answered Sep 25 '22 22:09

Ali Dehghani


If adding user to the docker group doesn't work then try restarting the service:

sudo service docker restart  
like image 28
Pratik Singhal Avatar answered Sep 26 '22 22:09

Pratik Singhal