# Docker image as jenkins worker

**URL:** <https://community.jenkins.io/t/docker-image-as-jenkins-worker/11122>\
**Category:** Ask a question\
**Tags:** question\
**Created:** [December 5, 2023, 5:19pm UTC](https://community.jenkins.io/t/docker-image-as-jenkins-worker/11122 "2023-12-05T17:19:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![quimicefa](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/quimicefa/32/6327_2.png) [@quimicefa](https://community.jenkins.io/u/quimicefa)\
**Post date:** [December 5, 2023, 5:19pm UTC](https://community.jenkins.io/t/docker-image-as-jenkins-worker/11122/1 "2023-12-05T17:19:56Z")

</div>

Jenkins setup:

## Jenkins: 2.332.3 OS: Linux - 3.10.0-1160.81.1.el7.x86\_64 Java: 11.0.17 - Eclipse Adoptium (OpenJDK 64-Bit Server VM)

TestComplete:2.8.1  
ace-editor:1.1  
allure-jenkins-plugin:2.30.2  
ansible:1.1  
ansicolor:1.0.2  
ant:475.vf34069fef73c  
antisamy-markup-formatter:2.7  
apache-httpcomponents-client-4-api:4.5.13-1.0  
artifact-repository-parameter:1.0.1  
artifactory:3.16.2  
audit-log:1.3  
audit-trail:3.10  
authentication-tokens:1.4  
badge:1.9.1  
bitbucket:223.vd12f2bca5430  
bitbucket-build-status-notifier:1.4.2  
bitbucket-oauth:0.12  
blueocean:1.25.5  
blueocean-autofavorite:1.2.5  
blueocean-bitbucket-pipeline:1.25.5  
blueocean-commons:1.25.5  
blueocean-config:1.25.5  
blueocean-core-js:1.25.5  
blueocean-dashboard:1.25.5  
blueocean-display-url:2.4.1  
blueocean-events:1.25.5  
blueocean-git-pipeline:1.25.5  
blueocean-github-pipeline:1.25.5  
blueocean-i18n:1.25.5  
blueocean-jwt:1.25.5  
blueocean-personalization:1.25.5  
blueocean-pipeline-api-impl:1.25.5  
blueocean-pipeline-editor:1.25.5  
blueocean-pipeline-scm-api:1.25.5  
blueocean-rest:1.25.5  
blueocean-rest-impl:1.25.5  
blueocean-web:1.25.5  
bootstrap4-api:4.6.0-5  
bootstrap5-api:5.1.3-7  
bouncycastle-api:2.26  
branch-api:2.1046.v0ca\_37783ecc5  
build-name-setter:2.2.0  
build-user-vars-plugin:1.9  
build-with-parameters:1.6  
caffeine-api:2.9.3-65.v6a\_47d0f4d1fe  
checks-api:1.7.4  
cloudbees-bitbucket-branch-source:773.v4b\_9b\_005b\_562b\_  
cloudbees-folder:6.729.v2b\_9d1a\_74d673  
clover:4.13.0  
cobertura:1.17  
code-coverage-api:2.0.4  
command-launcher:84.v4a\_97f2027398  
conditional-buildstep:1.4.2  
config-file-provider:3.10.0  
content-replace:1.7.0  
convert-to-pipeline:1.0  
copyartifact:1.43  
credentials:1087.1089.v2f1b\_9a\_b\_040e4  
credentials-binding:523.vd859a\_4b\_122e6  
cucumber-reports:5.7.1  
data-tables-api:1.12.1-1  
description-setter:1.10  
display-url-api:2.3.6  
docker-build-publish:1.3.3  
docker-commons:1.19  
docker-java-api:3.2.13-37.vf3411c9828b9  
docker-plugin:1.2.9  
docker-workflow:1.28  
durable-task:496.va67c6f9eefa7  
echarts-api:5.3.3-1  
email-ext:2.90  
extended-choice-parameter:346.vd87693c5a\_86c  
extended-read-permission:3.2  
external-monitor-job:191.v363d0d1efdf8  
favorite:2.4.1  
flexible-publish:0.16.1  
font-awesome-api:6.1.1-1  
forensics-api:1.15.1  
git:4.11.3  
git-client:3.11.0  
git-parameter:0.9.17  
git-server:1.11  
github:1.34.3  
github-api:1.303-400.v35c2d8258028  
github-branch-source:1637.vd833b\_7ca\_7654  
google-oauth-plugin:1.0.6  
google-play-android-publisher:4.2  
gradle:1.39.1  
groovy-postbuild:2.5  
h2-api:1.4.199  
handlebars:3.0.8  
handy-uri-templates-2-api:2.1.8-22.v77d5b\_75e6953  
hidden-parameter:0.0.5  
hp-application-automation-tools-plugin:7.5  
htmlpublisher:1.30  
http\_request:1.15  
image-tag-parameter:1.10  
ivy:2.2  
jackson2-api:2.13.3-285.vc03c0256d517  
jacoco:3.3.2  
jakarta-activation-api:2.0.1-2  
jakarta-mail-api:2.0.1-2  
javadoc:217.v905b\_86277a\_2a\_  
javax-activation-api:1.2.0-3  
javax-mail-api:1.6.2-6  
jaxb:2.3.6-1  
jdk-tool:1.5  
jenkins-design-language:1.25.5  
jjwt-api:0.11.5-77.v646c772fddb\_0  
job-dsl:1.81  
jobConfigHistory:1139.v888b\_656ca\_f6d  
jquery:1.12.4-1  
jquery-detached:1.2.1  
jquery-ui:1.0.2  
jquery3-api:3.6.0-4  
jsch:0.1.55.2  
junit:1119.1121.vc43d0fc45561  
ldap:2.10  
list-git-branches-parameter:0.0.11  
lockable-resources:2.15  
mail-watcher-plugin:1.17  
mailer:435.438.v5b\_81173f5b\_a\_1  
mapdb-api:1.0.9.0  
matrix-auth:2.6.6  
matrix-project:772.v494f19991984  
maven-plugin:3.19  
mercurial:2.16.2  
mina-sshd-api-common:2.8.0-21.v493b\_6b\_db\_22c6  
mina-sshd-api-core:2.8.0-21.v493b\_6b\_db\_22c6  
momentjs:1.1.1  
multiple-scms:0.8  
nodejs:1.5.0  
oauth-credentials:0.5  
okhttp-api:4.9.3-105.vb96869f8ac3a  
pam-auth:1.8  
parameterized-trigger:2.44  
pipeline-build-step:2.18  
pipeline-graph-analysis:195.v5812d95a\_a\_2f9  
pipeline-groovy-lib:593.va\_a\_fc25d520e9  
pipeline-input-step:449.v77f0e8b\_845c4  
pipeline-maven:3.11.0  
pipeline-milestone-step:101.vd572fef9d926  
pipeline-model-api:2.2097.v33db\_b\_de764b\_e  
pipeline-model-declarative-agent:1.1.1  
pipeline-model-definition:2.2097.v33db\_b\_de764b\_e  
pipeline-model-extensions:2.2097.v33db\_b\_de764b\_e  
pipeline-rest-api:2.24  
pipeline-stage-step:293.v200037eefcd5  
pipeline-stage-tags-metadata:2.2097.v33db\_b\_de764b\_e  
pipeline-stage-view:2.24  
pipeline-utility-steps:2.13.0  
plain-credentials:1.8  
plugin-util-api:2.17.0  
popper-api:1.16.1-3  
popper2-api:2.11.5-2  
publish-over:0.22  
publish-over-ssh:1.24  
pubsub-light:1.16  
quality-gates:2.5  
resource-disposer:0.20  
role-strategy:488.v0634ce149b\_8c  
run-condition:1.5  
scm-api:608.vfa\_f971c5a\_a\_e9  
script-security:1175.v4b\_d517d6db\_f0  
snakeyaml-api:1.30.1  
sonar:2.14  
sonar-quality-gates:1.3.1  
sse-gateway:1.25  
ssh-credentials:277.v95c2fec1c047  
ssh-slaves:1.31.2  
sshd:3.242.va\_db\_9da\_b\_26a\_c3  
stashNotifier:1.28  
structs:318.va\_f3ccb\_729b\_71  
subversion:2.15.5  
terraform:1.0.10  
throttle-concurrents:2.8  
timestamper:1.18  
token-macro:293.v283932a\_0a\_b\_49  
trilead-api:1.57.v6e90e07157e1  
variant:1.4  
windows-slaves:1.8.1  
workflow-aggregator:581.v0c46fa\_697ffd  
workflow-api:1182.v41475e53ea\_43  
workflow-basic-steps:980.v82219a\_ed188e  
workflow-cps:2725.v7b\_c717eb\_12ce  
workflow-cps-global-lib:588.v576c103a\_ff86  
workflow-durable-task-step:1164.v2334ddcf48d0  
workflow-job:1189.va\_d37a\_e9e4eda\_  
workflow-multibranch:716.vc692a\_e52371b\_  
workflow-scm-step:400.v6b\_89a\_1317c9a\_  
workflow-step-api:625.vd896b\_f445a\_f8  
workflow-support:820.vd1a\_6cc65ef33  
ws-cleanup:0.43

* * *

We’re running a quite old jenkins version, and I think the problem/misunderstanding is directly related to what can we get from docker-plugin or our approach.

The goal is getting a fleet of docker agents, with all relevant tools installed right there and get build/test of the projects happening in the docker containers and avoid the hassle of installing the toolset directly in the hosts (either controller or agents). Ideally on a remote docker/kubernetes host, but as a 1st approach we’re trying in the controller itself.

We’re using the [jenkins/inbound-agent](https://hub.docker.com/r/jenkins/inbound-agent) as base image extending it with our tools (maven, jdk, sonar scanner and many others). Defined the docker cloud, docker agent template and the pipeline is modified with a label to use those agents. Everything looks fine , the agent is started … BUT we are unable to access the agent’s workspace after the execution is completed. However, we can access it while the container is still running. Tried a lot of volume mounts, tweaks on docker image … but no luck. Also, this approach will not scale if we move the agents to a remote host.

So … is there any way to persist the workspace used by the container? We can always add an “archive” step to keep the relevant contents, but we miss the browse workspace feature when something goes south.

Are we missing something? any help will be appreciated. Also I wanted to check if you’all are discarding the workspace after job execution or if this requirement is too “strange”?

Thx,

---

<div class="post-metadata">

**Author:** ![rohiniintelliq](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/rohiniintelliq/32/16033_2.png) [@rohiniintelliq](https://community.jenkins.io/u/rohiniintelliq)\
**Post date:** [July 22, 2025, 7:06am UTC](https://community.jenkins.io/t/docker-image-as-jenkins-worker/11122/2 "2025-07-22T07:06:23Z")

</div>

Hey everyone,  
I’m a developer working on optimizing our Jenkins setup using Docker agents — part of our broader DevOps automation effort.

We’re still on an older Jenkins version, and I suspect some of our challenges might be related to that. We’re using a custom image based on `jenkins/inbound-agent`, with Maven, JDK, Sonar Scanner, etc., pre-installed. The goal is to keep our host machines clean and run all builds inside containers. So far, the agents start up fine, pipelines run as expected, and tools are working.

The problem: once the build is done and the container stops, we can no longer access the workspace. It’s there while the container is running, but gone afterwards — which makes debugging tricky. We’ve tried different volume mounts and tweaks in the Docker config, but still no luck.  
We’re planning to move agents to a remote Docker/Kubernetes host eventually, and this issue will become even more critical then.  
Is there a way to persist the workspace after the job finishes? Or is it expected behavior that everything is wiped once the container exits? We can archive artifacts, but losing the ability to browse the full workspace is a bit painful when troubleshooting.

Also, as someone diving deeper into container-based CI/CD, this aligns with a lot of concepts covered in [DevOps training in Hyderabad](https://intelliqit.com/) — but real-world usage always brings new surprises. Appreciate any tips or ideas.

Would love to hear how others are handling this — any suggestions are welcome. Thanks!
