Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Root cause of this error message is only that DOCKER_HOST variable has not been exported to all the users.
In my case it was working fine while I was running docker commands as root user but when I tried the same commands from Jenkins, didn't work. To understand this issue in detail let me create such environment and see troubleshooting steps.
[root@server106 ~]# hostname
server106.example.com
Docker Client -
[root@server109 ~]# hostname
server109.example.com
[root@server109 ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@server109 ~]# docker ps -a
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Solution:-
[root@server109 ~]# echo "export DOCKER_HOST=192.168.99.100:4243" >> /etc/profile
[root@server109 ~]# echo "export DOCKER_HOST=192.168.99.100:4243" >> /etc/bash_profile
[root@server109 ~]# echo "export DOCKER_HOST=192.168.99.100:4243" >> /etc/environment
[root@server109 ~]# source /etc/profile /etc/bash_profile /etc/environment
It must fix the issue, let's check if it has been fixed.
[root@server109 ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@server109 ~]# sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
Thank you for sharing your thoughts and knowledge on this topic.
ReplyDeleteDocker and Kubernetes Training
Docker and Kubernetes Online Training
Docker and Kubernetes Training in Hyderabad
Kubernetes Online Training
Docker Online Training
Docker Training in Hyderabad
Kubernetes Training in Hyderabad