Hi all - 

I have a docker host.  Jenkins ssh's (as the user jenkins) to this host via 
pipeline steps and builds apps inside the specified docker image.  This all 
pretty much flows as planned.  However... when the pipeline executes a 
"docker.insdie" or via pipeline -> agent -> docker, the docker image is 
always launched as the jenkins user.   Even if I specify "-u root" in the 
option, it's still has the "-u 501" which is the jenkins user.  

How can I get around this?   My build steps requires me to be able to 
create a /go/src/<etc> directory and the jenkins user doesn't have 
permissions to do this (it doesn't even exist on the docker image).   

Here's the output...  you can see that the docker run actually includes the 
-u 501 and the -u root.


[Pipeline] withDockerContainer
$ docker run -t -d -u 501:501 -u root -w /home/jenkins/workspace/ity-
service_tlester_jenkins-ZAK24AVEOSII6FI5ZPP6GCRQQ7ISJCROTD5BZVI3M4MT7EMS4ERA 
-v /home/jenkins/workspace/ity-service_tlester_jenkins-
ZAK24AVEOSII6FI5ZPP6GCRQQ7ISJCROTD5BZVI3M4MT7EMS4ERA:/home/jenkins/workspace
/ity-service_tlester_jenkins-
ZAK24AVEOSII6FI5ZPP6GCRQQ7ISJCROTD5BZVI3M4MT7EMS4ERA:rw -v /home/jenkins/
workspace/ity-service_tlester_jenkins-
ZAK24AVEOSII6FI5ZPP6GCRQQ7ISJCROTD5BZVI3M4MT7EMS4ERA@tmp:/home/jenkins/
workspace/ity-service_tlester_jenkins-
ZAK24AVEOSII6FI5ZPP6GCRQQ7ISJCROTD5BZVI3M4MT7EMS4ERA@tmp:rw -e ******** -e 
******** -e ******** -e ******** -e ******** -e ******** -e ******** -e 
******** -e ******** -e ******** -e ******** -e ******** -e ******** -e 
******** -e ******** -e ******** -e ******** -e ******** -e ******** -e 
******** -e ******** -e ******** -e ******** --entrypoint cat maven:3-alpine
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Example Build)
[Pipeline] sh
[ity-service_tlester_jenkins-
ZAK24AVEOSII6FI5ZPP6GCRQQ7ISJCROTD5BZVI3M4MT7EMS4ERA] Running shell script
+ ps -ef
PID USER TIME COMMAND
 1 root 0:00 cat
 7 root 0:00 sh -c echo $$ > 
'/home/jenkins/workspace/ity-service_tlester_jenkins-ZAK24AVEOSII6FI5ZPP6GCRQQ7ISJCROTD5BZVI3M4MT7EMS4ERA@tmp/durable-4de63803/pid'
; jsc=durable-8732979585d96e4fbbb59583fb030a62; JENKINS_SERVER_COOKIE=$jsc 
'/home/jenkins/workspace/ity-service_tlester_jenkins-ZAK24AVEOSII6FI5ZPP6GCRQQ7ISJCROTD5BZVI3M4MT7EMS4ERA@tmp/durable-4de63803/script.sh'
 
> 
'/home/jenkins/workspace/ity-service_tlester_jenkins-ZAK24AVEOSII6FI5ZPP6GCRQQ7ISJCROTD5BZVI3M4MT7EMS4ERA@tmp/durable-4de63803/jenkins-log.txt'
 
2>&1; echo $? > 
'/home/jenkins/workspace/ity-service_tlester_jenkins-ZAK24AVEOSII6FI5ZPP6GCRQQ7ISJCROTD5BZVI3M4MT7EMS4ERA@tmp/durable-4de63803/jenkins-result.txt'
 12 root 0:00 {script.sh} /bin/sh -xe /home/jenkins/workspace/ity-
service_tlester_jenkins-
ZAK24AVEOSII6FI5ZPP6GCRQQ7ISJCROTD5BZVI3M4MT7EMS4ERA@tmp/durable-4de63803/
script.sh
 13 root 0:00 ps -ef
[Pipeline] }
[Pipeline] // stage

[Pipeline] }
$ docker stop --time=1 
2955c0a99e3468245e1d72e9986af720b4be5f0eba05911d6de5f1e8919e8152
$ docker rm -f 
2955c0a99e3468245e1d72e9986af720b4be5f0eba05911d6de5f1e8919e8152
[Pipeline] // withDockerContainer
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline


-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/e1d77020-c9ec-40b1-877f-5eb7b27962a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to