我正在尝试从jenkins向docker部署映像,该映像也从docker运行。 从詹金斯,我得到以下堆栈跟踪:
Caused by: net.rubygrapefruit.platform.NativeException: Could not start 'docker'
at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:27)
at net.rubygrapefruit.platform.internal.WrapperProcessLauncher.start(WrapperProcessLauncher.java:36)
at org.gradle.process.internal.ExecHandleRunner.startProcess(ExecHandleRunner.java:98)
at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:71)
... 4 more
Caused by: java.io.IOException: Cannot run program "docker" (in directory "/var/jenkins_home/workspace/pipeline/build/docker"): error=13, Permission denied
at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:25)
... 7 more
Caused by: java.io.IOException: error=13, Permission denied
... 8 more
这是相关的詹金斯文件部分
stage('Deploy') {
steps {
sh './gradlew docker dockerRun --stacktrace'
}
}
,也是负责部署的gradle脚本的一部分
docker {
name "registry/spring-boot-api-example:1.1"
files "build/libs/${bootJar.archiveFileName.get()}"
buildArgs([JAR_FILE: bootJar.archiveFileName.get()])
}
以及包含jenkins容器配置的docker-comose文件
jenkins:
image: jenkins/jenkins:2.235.1-lts-centos7
privileged: true
hostname: jenkins
user: root
ports:
- '8080:8080'
- '50000:50000'
container_name: jenkins
environment:
- JENKINS_OPTS="--prefix=/jenkins"
volumes:
- ./jenkins:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
- /usr/local/bin/docker:/usr/local/bin/docker