0

/var/jenkins_home/workspace/faceapp_main@tmp/durable-7343158a/script.sh: 1: docker-compose: Permission denied

I'm using Jenkins to automate pipeline including build and push images to dockerhub using docker-compose. But I got this error ...

I realize one weird thing is that I can run docker, but not docker-compose in Jenkins

Max Ph
  • 1
  • 1
  • Does this answer your question? [Docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock](https://stackoverflow.com/questions/47854463/docker-got-permission-denied-while-trying-to-connect-to-the-docker-daemon-socke) – juanlumn May 23 '23 at 13:49
  • Are you running the dokcer image with root access? – Nitin k May 23 '23 at 14:18
  • you can try "chmod 777 /var/jenkins_home/workspace/*" – Nitin k May 23 '23 at 14:18
  • I actually tried the solutions above but it did not work. Btw I'm using Macos ... – Max Ph May 23 '23 at 14:35

1 Answers1

0
  • if the permission denied because you can't access /var/run/docker.sock , you can try sudo chmod 666 /var/run/docker.sock
  • if the permission denied because you need root privilege to run docker commands on your machine, you need to make the jenkins user have root privilege without the need to use sudo, you can try this

$ sudo visudo

Now add the below lines in your sudoers file :

jenkins ALL=(ALL) NOPASSWD: ALL 

then restart your jenkins service
$service jenkins restart

  • I tried it, but it didn't work. I realize one weird thing is that I can run docker, but not docker-compose in Jenkins(as I described)... – Max Ph May 25 '23 at 12:49