introduction: I'm trying to build an Angular app on the slave, In order not to install nodejs on the slave I use docker on the slave to build and cleanup.
The problem
run docker commands directly on the slave with the Jenkins user works well
jenkins@ubuntu_server:~$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete
...
When the jenkinsfile try to run docker commands on the slave it fails with permission denied error.
+ docker inspect -f . node:current-alpine3.10
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.40/containers/node:current-alpine3.10/json: dial unix /var/run/docker.sock: connect: permission denied
here relevant jenkinsfile part "ubuntu_server" is a label of the slave
pipeline {
agent {
docker {
image 'node:current-alpine3.10'
label 'ubuntu_server'
args '-v /tmp:/tmp'
}
}