Well, generally, this type of issue occurs when running various docker commands like docker info, docker pull, docker stop, docker run, etc. However, you don’t have to worry about it as we have compiled a few fixes in this article that will help you fix the error message that cannot connect to the docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? So, let’s get started with them.
What is Docker Daemon?
Docker Daemon is a process that manages container images, networks, and storage volumes. Throughout the process, the Docker daemon monitors for requests made through the Docker API.
1 What is Docker Daemon?2 How to Fix Cannot Connect to the Docker Daemon2.1 Fix 1: Clean a ‘Failed Docker Pull’ and Start Docker Service2.2 Fix 2: Run the Docker Service with systemctl2.3 Fix 3: Run Docker with the Service Command2.4 Fix 4: Run Dockerd (Docker Daemon) Service2.5 Fix 5: Run Docker for Users Without Root Privileges2.6 Fix 6: Run Docker Service with Snap2.7 Fix 7: Reinstall The Docker2.8 Sum Up | Start Docker Daemon
In addition to responding to Docker API requests, the Docker daemon (dockerd) manages Docker objects, including images, containers, networks, and volumes. As part of Docker service management, daemons can communicate with each other.
How to Fix Cannot Connect to the Docker Daemon
The developers’ complaints drove us to develop effective solutions. A number of factors can cause this error, including Docker not running, When Docker is shutdown, it doesn’t do so cleanly, and Docker cannot be started due to a lack of root privileges. So, as you understand the root cause of your problem, i.e., cannot connect to the docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?; therefore, let’s look at some possible solutions.
Fix 1: Clean a ‘Failed Docker Pull’ and Start Docker Service
The Docker application might unexpectedly close during container pull, due to which you are getting this type of error. Docker’s service and socket files will be hidden in such circumstances. In order to communicate with Docker, a file called Docker.socket can be found at /var/run/docker.sock. Therefore, Docker will not start until we unmask the two files – Docker.service and docker.daemon.
Open Terminal and use these commands:systemctl unmask docker.service systemctl unmask docker.socket systemctl start docker.service
Now, we will need to delete the files from the Containers directory before restarting Docker if you are still experiencing the error after executing the commands below. Then, run this command. Nevertheless, make sure you know the root password, as we will require elevated privileges.sudo su service docker stop cd /var/run/docker/libcontainerd rm -rf containerd/* rm -f docker-containerd.pid service docker start
Fix 2: Run the Docker Service with systemctl
There is a high probability that Docker’s service is not running if you just installed Docker on Ubuntu or rebooted your PC. It is the Docker daemon (dockerd) that provides service to Docker. A Docker API request is received here from the service, and it deals with various Docker objects such as images, containers, networks, and volumes. Using systemctl, you can manage the system services running in Linux, replacing the old SysV init system. The service command can be used if you don’t have systemctl installed. However, in case you don’t know how to do this, make sure to perform these steps:
Open Windows Terminal and execute the command to unmask Docker:sudo systemctl unmask docker
A mask can be thought of as a more robust version of disabling Docker.service. The error will appear if we attempt to start the service while the unit is masked. Masked unit files are linked to the device dev/null. With the command $ systemctl list-unit-files, you can list the status of all unit files.
The systemctl command can be used once the docker unit is unmasked. Execute this command:systemctl start docker
Verify that Docker is running and active. To view the current status of a service, we will use the systemctl status command. You can execute this command:systemctl status docker
Fix 3: Run Docker with the Service Command
If the above method doesn’t work for you, then there are chances that your device may use the SysC init system. Well, if that’s the case, then chances are there that the systemctl command may not work for you. Instead, you will have to use the service command to run the Docker Daemon without getting the error message cannot connect to the docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? So, let’s see how you do it:
Open Windows Terminal and execute this command:sudo service –status-all sudo service docker start
Fix 4: Run Dockerd (Docker Daemon) Service
You can also use the Dockerd service to run the Docker Daemon in case none of the above method work for you. However, to use the Dockerd service, you need to perform these steps:
Fix 5: Run Docker for Users Without Root Privileges
There are several users who reported that running the Docker without root privileges helps them to fix the error message that “cannot connect to the docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?” So, let’s check out the steps:
Fix 6: Run Docker Service with Snap
If you installed it using Snap package manager, the Docker could be managed with the snap command. This is because the services managed by Snap are generally automated. It may, however, be necessary to interfere manually in situations like this. Therefore, to use this in order to run the Docker, you have to perform these steps:
Open Windows Terminal and execute the command:sudo snap start docker
Once the above command is executed, then run this command:sudo snap services
Fix 7: Reinstall The Docker
If you have already tried all the above-mentioned fixes to resolve the error message “cannot connect to the docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?”, then except for reinstalling the Docker on your PC, you have to option left. However, in case you don’t know how to reinstall the Docker, you can go to the Ubuntu official website and check how to do this.
Sum Up | Start Docker Daemon
So, that’s how to fix the error message that cannot connect to the docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? We hope that you find this troubleshooting article helpful. But, in case you have any doubts or queries on your mind, comment below and let us know. Also, don’t forget to check out our other guide at iTechHacks. RELATED ARTICLES:
How To Fix Windows Can’t Find One Of The Files In This ThemeFix ‘Unexpected Error With Login Session’ in League Of LegendsHow To Fix Windows 11 Blue Screen of Death ErrorsFix Adobe CEF Helper.exe Causing High CPU In Windows PCHow to Fix ‘Unfortunately, Email Has Stopped’ Error On Galaxy S10/S20
Δ