Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running?

1,048,096

Solution 1

You can try out this:

systemctl start docker

It worked fine for me.

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

gpasswd -a $USER docker

Solution 2

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.

Solution 3

You can get this error if docker doesn't shut down cleanly. The following answer is for the docker snap package.

Run snap logs docker and look for the following:

Error starting daemon: pid file found, ensure docker is not running or delete /var/snap/docker/179/run/docker.pid

Deleting that file and restarting docker worked for me.

rm /var/snap/docker/<your-version-number>/run/docker.pid
snap stop docker
snap start docker

Make sure to replace ‍‍‍‍<your-version-number>‍ with the appropriate version number.

Solution 4

Easy way to fix this issue, try this

sudo su
systemctl start docker
systemctl enable docker
systemctl restart docker

Solution 5

I just hit this after doing a fresh install of DOCKER from the main docs. The problem for me was that immediately after the install, the service is not running.

These commands will help you to make sure docker is up and running for your run command to find it:

$ sudo service --status-all 
$ sudo service docker start
$ sudo service docker start
Share:
1,048,096
Umair Ayub
Author by

Umair Ayub

** I am currently looking for a Software Engineer opportunity outside Pakistan, preferably Europe ** I am a full time freelancer and I develop Web Scraping applications. You can contact me on iamumairayub AT gmail DOT com if you need my services.

Updated on February 18, 2022

Comments

  • Umair Ayub
    Umair Ayub about 2 years

    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