The Error “Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running?”, is an error that is invoked when you are working on a docker and want to use scrapy splash on the server. Given below is the snippet of the error you might get:
Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running?
I would like to share with you the steps I took to fix the “Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running?”
Why “Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running?” Error is Seen?
The error, “Cannot connect to the Docker daemon at unix:/var/run/docker.sock. is the docker daemon running?” is seen most probably because of unproper docker shut down last time. if docker doesn’t shut down cleanly the error Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running? is seen.
The detailed solution to fix the error “Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running?”, is given below:
How to fix “Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running?” Error?
To fix the error, you will have to restart docker by running the appropriate commands. You can also use dockerd as dockerd is the daemon service for docker containers, because it is not running in the background. If you still face the error you will have to uninstall and re-install docker as a final solution.
To fix the error, “Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running?”, you will have to follow the below-mentioned steps:
First you will have to run the below mentioned code:
systemctl start docker
Running the above mentioned command “systemctl start docker” should fix the error “Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running?” immediately.
Please make a note that if after running the above mentioned commands that you can not do without sudo, use the below mentioned code:
gpasswd -a $USER docker
If you are still facing the error even after following the above steps, you will have to run the below mentioned command:
sudo dockerd
The above command dockerd is the daemon service for docker containers, because it is not running in the background we are not able to take any actions related to the service, which needs to be restarted.
If you still face the error you will have to uninstall and re-install docker as a final solution.
This should fix the error, “Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running?”
Conclusion
To fix the error “Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running?”, you will have to restart docker by running the appropriate commands.
You can also use dockerd as dockerd is the daemon service for docker containers, because it is not running in the background. If you still face the error you will have to uninstall and re-install docker as a final solution.