web analytics

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!

One comment to 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

  • Captain Kill  says:

    This solution is like a rash all over the internet.

    So, what happened at the next reboot?

Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>