If you are getting an error “Cannot connect to the Docker daemon at unix:/var/run/docker.sock”, make sure your docker service is running.
Check the current status of the docker service:
1 2 |
## Check the current status of docker service sudo systemctl status docker # sudo service docker status |
If the docker service is in a stopped state, start it:
1 2 3 4 |
## If docker service not running, start and enable it sudo systemctl start docker # sudo service docker start sudo systemctl enable docker # sudo service docker enable sudo systemctl status docker # sudo service docker status |
Note: if you get an error “Failed to start docker.service: Unit docker.service is masked”, you need to unmask the docker service first before trying to start.
Unmask the docker service:
1 2 |
## unmask the docker service sudo systemctl unmask docker # sudo service docker unmask |
You can also try to restart the docker service and see if it works.
1 2 3 |
## You can also try to restart the docker service and see if it works sudo systemctl restart docker # sudo service docker restart sudo systemctl status docker # sudo service docker status |