Here is my Jenkinsfile
pipeline in a project
pipeline {
agent {
docker {
image 'docker:dind'
args '-u root:root -p 3000:3000 --privileged'
}
}
environment {
CI = 'true'
}
stages {
stage('docker build') {
when {
branch 'master'
}
steps {
sh 'docker build --label v1.0.0 -t myrepo/myapp:v1.0.0'
}
}
}
}
And I have a jenkins master and slave agent respectively. The above pipeline works well in master node, but if run in a slave agent node, then it would met the following error:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
I am pretty sure that docker is running on the agent node because I can ssh to it and run docker commands successfully.
Why it behaves differently between running on master and slave agent? How should I fix it? Thanks very much!
args "-u root:root"
part, I have forced use the root user so it should not have permissions issue, right? - Jeff Tian