我已经让Jenkins在一个码头集装箱中运行,并使用swarm代理。
我创建了一个码头工作量:' maven-repository'并且可以获得访问它的工作(缓存maven)。但是,如果两个作业同时运行,我会收到权限被拒绝错误,下面的示例日志:
其他人有这个问题并设法解决了吗?我还试过挂载/var/jenkins_home/.m2:/tmp/.m2
成功运行:
Running on Jenkins in /var/jenkins_home/workspace/Alex Test
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Agent Setup)
[Pipeline] sh
[Alex Test] Running shell script
+ docker pull maven:3.5.3-jdk-8-alpine
3.5.3-jdk-8-alpine: Pulling from library/maven
Digest: sha256:d8c6a5fef17ae7fcb2629e558554a085e90c722796306f31bee7fb7b9a5a123e
Status: Image is up to date for maven:3.5.3-jdk-8-alpine
[Pipeline] }
[Pipeline] // stage
[Pipeline] sh
[Alex Test] Running shell script
+ docker inspect -f . maven:3.5.3-jdk-8-alpine
.
[Pipeline] withDockerContainer
Jenkins seems to be running inside container 73c7522e3a5de318e5500a6092974cc78ab5eedf4de70b18d264aeb40e40b360
$ docker run -t -d -u 1000:1000 --privileged -v maven-repository:/tmp/.m2 -v /var/run/docker.sock:/var/run/docker.sock -w "/var/jenkins_home/workspace/Alex Test" --volumes-from 73c7522e3a5de318e5500a6092974cc78ab5eedf4de70b18d264aeb40e40b360 -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** maven:3.5.3-jdk-8-alpine cat
$ docker top 9902bb5b16a8b5a0b5ee16f2a0c87ea9961fe06c895b859f96142adf388be1b9 -eo pid,comm
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Check Maven Directory)
[Pipeline] sh
[Alex Test] Running shell script
+ ls /tmp
[Pipeline] sh
[Alex Test] Running shell script
+ ls /tmp/.m2
hsperfdata_root
repository
[Pipeline] sh
[Alex Test] Running shell script
+ cat /dev/urandom
+ fold -w 32
+ head -n 1
+ tr -dc a-zA-Z0-9
+ touch /tmp/.m2/68rS0lsIiml0cIg2bJ8BooxltUqJy31X
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
$ docker stop --time=1 9902bb5b16a8b5a0b5ee16f2a0c87ea9961fe06c895b859f96142adf388be1b9
$ docker rm -f 9902bb5b16a8b5a0b5ee16f2a0c87ea9961fe06c895b859f96142adf388be1b9
[Pipeline] // withDockerContainer
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
如果同时运行作业:
[Pipeline] withDockerContainer
swarm-agent seems to be running inside container 9475a72289efb2b4a0918fa5127514e81bea82b90720dd859380fe9ffc1f4d92
$ docker run -t -d -u 10000:10000 --privileged -v maven-repository:/tmp/.m2 -v /var/run/docker.sock:/var/run/docker.sock -w "/home/jenkins/agent/workspace/Alex Test@3" --volumes-from 9475a72289efb2b4a0918fa5127514e81bea82b90720dd859380fe9ffc1f4d92 -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** maven:3.5.3-jdk-8-alpine cat
$ docker top b7b9793e52ae9497209b7469c936e98d157d408ad5235776e26b3c05c2a151da -eo pid,comm
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Check Maven Directory)
[Pipeline] sh
[Alex Test@3] Running shell script
+ ls /tmp
[Pipeline] sh
[Alex Test@3] Running shell script
+ ls /tmp/.m2
[Pipeline] sh
[Alex Test@3] Running shell script
+ fold -w 32
+ cat /dev/urandom
+ tr -dc a-zA-Z0-9
+ head -n 1
+ touch /tmp/.m2/8lqaDHloPUqmw6a4Wr3aky7AZdDhMIrW
touch: /tmp/.m2/8lqaDHloPUqmw6a4Wr3aky7AZdDhMIrW: Permission denied
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
$ docker stop --time=1 b7b9793e52ae9497209b7469c936e98d157d408ad5235776e26b3c05c2a151da
$ docker rm -f b7b9793e52ae9497209b7469c936e98d157d408ad5235776e26b3c05c2a151da
[Pipeline] // withDockerContainer
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE
答案 0 :(得分:0)
我们发现master正在运行我们的第一个具有docker卷的作业,但是运行多个作业会导致使用没有docker卷的slave。