Cannot connect to the Docker daemon at unix:/var/r

2020-02-07 14:04发布

I have applied every solution available on internet but still I cannot run Docker.

I want to use Scrapy Splash on my server.

Here is history of commands I ran.

docker run -p 8050:8050 scrapinghub/splash
sudo docker run -p 8050:8050 scrapinghub/splash
sudo usermod -aG docker $(whoami)
sudo docker run -p 8050:8050 scrapinghub/splash
newgrp docker
sudo docker run -p 8050:8050 scrapinghub/splash
reboot
sudo docker run -p 8050:8050 scrapinghub/splash
docker run -p 8050:8050 scrapinghub/splash

You can see I tried to restart my server as well, but it didnt help.

see output of ps -aux | grep docker

root@mani:/var/www/html# ps aux | grep docker
root      8524  0.0  0.8 127904 13964 ?        Ssl  17:21   0:00 /usr/bin/dockerd --raw-logs
root      8534  0.0  0.3  90588  5012 ?        Ssl  17:21   0:00 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --shim docker-containerd-shim --runtime docker-runc
root      8543  0.0  0.0   8812   764 pts/1    S+   17:21   0:00 grep --color=auto docker
root     16356  0.0  0.0  17200   964 pts/1    S    17:14   0:00 newgrp docker
root     20080  0.0  0.0  17200   964 pts/1    S    17:06   0:00 newgrp docker
root     30221  0.0  0.0  17200   964 pts/1    S    17:09   0:00 newgrp docker

20条回答
Root(大扎)
2楼-- · 2020-02-07 14:49

For me the solution was to simply make sure I had installed the correct Docker package. For example, for Ubuntu the depreciated packages are:

  • docker
  • docker-engine
  • docker.io
  • containerd
  • runc

For installation check https://docs.docker.com. Instructions are provided for Ubuntu, CentOS, Debian and Fedora at the time of writing.

查看更多
够拽才男人
3楼-- · 2020-02-07 14:49

It could be related to no disk space left on the hard drive. Make sure you have space left on the device, Docker can't start up if there isn't any space left.

查看更多
趁早两清
4楼-- · 2020-02-07 14:49

This exception comes when the service of docker is not running or the logged in user dont have the permission to access docker and generally it comes in RedHat

Using below command should resolve the issue

sudo service docker start

enter image description here

查看更多
叛逆
5楼-- · 2020-02-07 14:50

You can try out this :

systemctl start docker

It worked fine for me.

Ps: after if there is commands that you can't do without sudo, try this :

gpasswd -a $USER docker
查看更多
一夜七次
6楼-- · 2020-02-07 14:54

First, try with sudo, as the current user may not have access permissions to communicate to docker daemon i.e. /var/run/docker.sock

If its still not working, then, after the installation, simply stop the docker daemon as,

$ sudo service docker stop

And, run the following command to start the daemon in background,

$ sudo nohup docker daemon -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock

To make working with Docker easier, you should add your username to the Docker users group. Adding a user to the group can be done with the command below

$ sudo usermod -aG docker $USER

Also, this step is mention at official documentation of docker Post-installation steps for Linux (https://docs.docker.com/engine/installation/linux/linux-postinstall/)

The Ubuntu 16.04 users can follow these steps,

Inside file /lib/systemd/system/docker.service change: ExecStart=/usr/bin/dockerd fd:// with ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375

Inside file /etc/init.d/docker change:

DOCKER_OPTS= with DOCKER_OPTS="-H ****tcp://0.0.0.0:2375 "

and then restart your machine. And, start playing with docker.

查看更多
何必那么认真
7楼-- · 2020-02-07 14:55

Just Run

sudo dockerd

dockerd is the daemon service for docker containers, because it is not running in background we're not able to take any actions related to the service, which needs be restarted.

查看更多
登录 后发表回答