0
votes

Hi…I am running my Jenkins job on windows os. I am building war file on slave node which is in AWS- ubuntu 18.07 server. My Docker is installed on my slave node. My Docker file is in workspace. But while building the image I am facing error:

I have already added my slave node user to Docker group & inside slave node workspace (ubuntu server) , I am able to create same image without using sudo.

docker build -t swagats/helloimage .

But still I am facing the error in Jenkins. Please help me.

[slaveAnsibleDocker] $ docker build -t swagats/helloimage --pull=true /home/ubuntu/workspace/slaveAnsibleDocker 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.39/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile&labels=%7B%7D&memory=0&memswap=0&networkmode=default&pull=1&rm=1&session=utpwhi2ue7xox69p9mibabkb7&shmsize=0&t=swagats%2Fhelloimage&target=&ulimits=null&version=1: dial unix /var/run/docker.sock: connect: permission denied Build step ‘Docker Build and Publish’ marked build as failure

Finished: FAILURE
1

1 Answers

0
votes

you have to give the root credentials to jenkis itself jenkins is a separate user because it's a web server right and Any commands that you execute through jenkins it would be executed as the user jenkins so what you have to do is creating a new docker group and add your user; The user from which you're executing
Similar to that you have to add your jenkins user to the docker group, and you should give the docker group the root access
So the docker group would basically be on par with root in terms of the access that it has over the system so that's the important step that you need to do because otherwise if you don't enable this acces then your command want be executed and it would say failure permission denied