Cannot connect to the Docker daemon

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

Above message appears when we try to get the info of the Docker or check the status of docker upon installation. I have used CENT OS as part of Docker installation. Below is the error message.

docker –version command gives output of the Docker that is installed on OS. Whereas, docker info command fails to provide information. docker version command gives info about client and not about server daemon process.

Cannot connect to the Docker daemon

 

Resolution

1. Check if the user is part of sudoers group or assign sudo provileges to the user. User which we are trying to start the docker should be having sudo access. If you have installed docker using Non Root user, then follow the last message provided during the final step of installation process.

Below message comes up during Installation of Docker,

If you would like to use Docker as a non-root user, you should now consider
adding your user to the “docker” group with something like:

sudo usermod -aG docker your-user

Adding a user to the “docker” group will grant the ability to run containers which can be used to obtain root privileges on the docker host.

Cannot connect to the Docker daemon

2. Run the Docker service manually. Use dockered & so that it runs as a service in the background or use service docker start command for starting the docker.

Cannot connect to the Docker daemon

Check the status of docker after performing any one of the above actions,

systemctl status docker

ps -ef|grep docker

Cannot connect to the Docker daemon

Cannot connect to the Docker daemon

 

URLs below for reference,

https://docs.docker.com/engine/admin/

https://forums.docker.com/t/cannot-connect-to-the-docker-daemon-is-the-docker-daemon-running-on-this-host/8925