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

20 views
Skip to first unread message

Vincent Massol

unread,
Feb 4, 2019, 7:45:47 AM2/4/19
to Jenkins Users
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
Message has been deleted

Vincent Massol

unread,
Feb 4, 2019, 7:50:29 AM2/4/19
to Jenkins Users
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)
...



Vincent Massol

unread,
Feb 4, 2019, 11:41:31 AM2/4/19
to Jenkins Users
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

Vincent Massol

unread,
Feb 5, 2019, 8:36:20 AM2/5/19
to Jenkins Users
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
Reply all
Reply to author
Forward
0 new messages