web analytics

Monthly Archives November 2019

Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.39/containers/nginx/json: dial unix /var/run/docker.sock: connect: permission denied

I was getting this error when I was trying to run a docker container using jenkins declarative pipeline script. This was being run on my localhost and below is what I needed to correct it.

Added jenkins user to docker group

sudo usermod -a -G docker jenkins

The solution that actually worked was to change the permission of the sock file to 666

devops-04:~$ ls -al /var/run/docker.sock
srw-rw—- 1 root docker 0 Oct 28 11:54 /var/run/docker.sock

devops-04:~$ sudo chmod 666 /var/run/docker.sock

devops-04:~$ ls -al /var/run/docker.sock

 

Once this was done my pipeline script started working!

Read More