Docker Community Forums

Share and learn in the Docker community.

Getting “Permission Denied” error when trying to build a docker image in Jenkins on Mac

(Jmojnida) #1

I am using Jenkins version 2.121.1 with Pipeline On MacOS-HighSierra.

I’ve a shell script called that builds a docker image using the following command:

docker build -t test_api:1 -f test-dockerfile
test-dockerfile is a Dockerfile and has instructions to build an image.

From CLI the whole set up works! However, when I run it from Jenkins server Pipeline context, it is failing at the above line with an error:

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.37/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=.dockerfile.14bce80e6f0b4b9d7b36&labels=%7B%7D&memory=0&memswap=0&networkmode=default&rm=1&session=2fab4ca31a7ca7b7eceddf80e02de5a7089dc10f50db250d2249e059d7ecfb61&shmsize=0&t=login_api%3A100_i&target=&ulimits=null: dial unix /var/run/docker.sock: connect: permission denied

The step that triggers from Jenkins server is simple. Just call the script:

stage (‘Build-Docker-Image’) {
steps {
sh ‘/path/to/’
I made sure Jenkins user has “admin” permission and member of “staff” group. I printed out them in the shell script too as below:

jenkins ID = uid=267(jenkins) gid=20(staff) egid=1(daemon) groups=267(jenkins),12(everyone),20(staff),61(localaccounts),80(admin),701(,33(_appstore),98(_lpadmin),100(_lpoperator),204(_developer),250(_analyticsusers),395(,398(,399(

I followed the workaround steps mentioned here: I’ve rebooted Docker on my Mac several times too. It did not help.

(Jmojnida) #2

Any suggestions on this?

(Ramanurs) #3

Did you find any solution this issue, I am also facing same issue.
I have Jenkins & dockers installed on my mac.
When I login as Jenkins user I am getting permission denied error.
I tried all work arounds found by googling but none helped. I have created docker group, added jenkins user to this group. I even added jenkins to staff, admin groups but still same error.

Anyone any leads on this issue would greatly appreciate.