0
docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/create: dial unix /var/run/docker.sock: connect: permission denied.

I'm getting this whenever I try to run Docker inside Jenkins. The machine was installed using the Bitnami Jenkins image. I have exhausted every troubleshooting option I can think of in an effort to solve what should be a simple permissions issue, but keep coming up empty.

I have attempted all the suggestions here at this Stack Overflow thread. I have attempted adding jenkins, bitnami, azureuser and anyone else on the system that looks like they might run Docker to the docker group using sudo usermod -a -G docker <user>.

I can sudo su - jenkins and docker run hello-world without issues.

Yet, still, no matter what I do, I am reduced to this error.

sudo usermod -aG docker $USER does nothing. sudo usermod -a -G docker bitnami does nothing. sudo usermod -a -G docker jenkins does nothing. sudo usermod -a -G docker literallyanyusericanthinkof does nothing. Rebooted/restarted hundreds of times now, no help.

I can run Docker in literally any other context on the machine, but Jenkins still refuses to run it. I am at my whits end getting this to work. I've configured at least two other Jenkins servers to do this before, but this one is giving me grief and I have no idea why.

Can anyone point me in the right direction?

Kirk Sefchik
  • 673
  • 1
  • 9
  • 22

3 Answers3

2

So I don't necessarily feel good about this, but I ran into this issue today and I got around it by changing the ownership on the docker.sock file in /var/run to jenkins:docker and now my Jenkins is working. The command I ran was

sudo chown jenkins:docker /var/run/docker.sock
0

I'm not using Jenkins, but for my personal account, my method was similar to @benjaminpazienza above. I also don't feel great about it but it works.

sudo chmod 666 /var/run/docker.sock
0

I ran into the same problem, Jenkins restart didn't work as well.

I found that restarting the machine hosting the Jenkins will fix it. Avoid giving r/w access to others by chmod as much as you can.

HatsOn
  • 67
  • 1
  • 9