Is it possible to not remove the docker agent container after job execution?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Is it possible to not remove the docker agent container after job execution?

Vincent Massol
Hi Jenkins users/devs,

I'm testing Jenkins with agents spawned as docker containers (I have my own custom docker image built on top of "jenkins/ssh-slave").

However, one important is when a job fails and I need to debug it, since by default the spawned docker container is removed when the job finishes.

I couldn't find any option in the jenkins system configuration, under "Docker Agent templates" to mention to not remove the container.

Can this be achieved? How do you debug?

Actually I don't need to keep the container per see but I'd need at least to keep the workspace so that I could start a new docker agent on that workspace, if I need to debug a job and reproduce a problem.

Thanks
-Vincent

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/d20f8772-bd5b-476b-8030-e1bc3a7738b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to not remove the docker agent container after job execution?

Vincent Massol
For example I just got the following failure on my job running inside a docker agent container 

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/164b92ae-9375-492e-b993-7ad96c4caff8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to not remove the docker agent container after job execution?

Vincent Massol
In reply to this post by Vincent Massol
For example I just got the following failure on my job running inside a docker agent container and I can't go there to open the file and see what was the problem:

[INFO] --- maven-failsafe-plugin:2.22.0:verify (functional-tests) @ xwiki-platform-menu-test-docker ---
[ERROR] There are test failures.


Please refer to /root/workspace/VincentDockerTest/master/xwiki-platform-core/xwiki-platform-menu/xwiki-platform-menu-test/xwiki-platform-menu-test-docker/target/failsafe-reports for the individual test results.
Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
org
.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
Command was /bin/sh -c cd /root/workspace/VincentDockerTest/master/xwiki-platform-core/xwiki-platform-menu/xwiki-platform-menu-test/xwiki-platform-menu-test-docker && /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -jar /root/workspace/VincentDockerTest/master/xwiki-platform-core/xwiki-platform-menu/xwiki-platform-menu-test/xwiki-platform-menu-test-docker/target/surefire/surefirebooter7860732879842186072.jar /root/workspace/VincentDockerTest/master/xwiki-platform-core/xwiki-platform-menu/xwiki-platform-menu-test/xwiki-platform-menu-test-docker/target/surefire 2019-02-04T12-39-38_639-jvmRun1 surefire1791618329575763865tmp surefire_0240282345495838647tmp
Error occurred in starting fork, check output in log
Process Exit Code: 1
 at org
.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:671)
 at org
.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:533)
...



--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/f31e4122-31d4-40ed-8506-20134fb26c18%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to not remove the docker agent container after job execution?

Vincent Massol
The doc at https://plugins.jenkins.io/docker-plugin says: 

Optionally, the container can be committed, so that (for example) manual QA could be performed by the container being imported into a local docker provider, and run from there.


How can that be achieved?

Thanks
-Vincent

Le lundi 4 février 2019 13:50:29 UTC+1, Vincent Massol a écrit :
For example I just got the following failure on my job running inside a docker agent container and I can't go there to open the file and see what was the problem:

[INFO] --- maven-failsafe-plugin:2.22.0:verify (functional-tests) @ xwiki-platform-menu-test-docker ---
[ERROR] There are test failures.


Please refer to /root/workspace/VincentDockerTest/master/xwiki-platform-core/xwiki-platform-menu/xwiki-platform-menu-test/xwiki-platform-menu-test-docker/target/failsafe-reports for the individual test results.
Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
org
.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
Command was /bin/sh -c cd /root/workspace/VincentDockerTest/master/xwiki-platform-core/xwiki-platform-menu/xwiki-platform-menu-test/xwiki-platform-menu-test-docker && /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -jar /root/workspace/VincentDockerTest/master/xwiki-platform-core/xwiki-platform-menu/xwiki-platform-menu-test/xwiki-platform-menu-test-docker/target/surefire/surefirebooter7860732879842186072.jar /root/workspace/VincentDockerTest/master/xwiki-platform-core/xwiki-platform-menu/xwiki-platform-menu-test/xwiki-platform-menu-test-docker/target/surefire 2019-02-04T12-39-38_639-jvmRun1 surefire1791618329575763865tmp surefire_0240282345495838647tmp
Error occurred in starting fork, check output in log
Process Exit Code: 1
 at org
.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:671)
 at org
.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:533)
...



--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/1eb9835d-b428-45aa-9c58-58b351533be5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to not remove the docker agent container after job execution?

Vincent Massol
In reply to this post by Vincent Massol
Some progress thanks to Jesse Glick.

Answer: you have to fill the "Docker Command” field under "Docker Agent templates” (under “Cloud”). I assume that by default Jenkins is passing the  —rm options when executing the docker command and this is why we need an override.

It works but but strangely I don’t see the workspace in the container even though the pipeline logs says it’s in /root/workspace. Maybe some mounts are done for the workspace by default (even though I didn't pass any mount in my command)?

FTR the command I've used is "docker run -v /var/run/docker.sock:/var/run/docker.sock xwiki/xwiki-jenkins-slave”

Any idea?

Thanks
-Vincent


Le lundi 4 février 2019 13:45:47 UTC+1, Vincent Massol a écrit :
Hi Jenkins users/devs,

I'm testing Jenkins with agents spawned as docker containers (I have my own custom docker image built on top of "jenkins/ssh-slave").

However, one important is when a job fails and I need to debug it, since by default the spawned docker container is removed when the job finishes.

I couldn't find any option in the jenkins system configuration, under "Docker Agent templates" to mention to not remove the container.

Can this be achieved? How do you debug?

Actually I don't need to keep the container per see but I'd need at least to keep the workspace so that I could start a new docker agent on that workspace, if I need to debug a job and reproduce a problem.

Thanks
-Vincent

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/a794402f-1749-4c73-b7f5-82ed33bf1c57%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.