jenkinsci / jenkinsci/docker-workflow-plugin

[JENKINS-68955] Implement .inside{} wrapper for Container object

Open
#694 0 comments 0 reactions 0 assignees View on GitHub
component:docker-workflow-plugin enhancement imported-jira-issue priority:minor resolution:unresolved
Dominant language
Java
Stars
527
Forks
422
Avg merge
10m
Merged PRs (30d)
1

Description

Currently the workflow described in docs is something like this:

docker.image('alpine').inside {

sh 'X'
sh 'Y'
}

It does not address the situations when you need to:



  1. run X  in container

  2. run Y in host agent

  3. run Z in the same container, preserving changes from 1

The only solution to that, AFAIK, is something like this:

docker.image('alpine').withRun { container ->

sh "docker exec ${container.id} X"
sh "Y"
sh "docker exec ${container.id} Z"
}

As mentioned in JENKINS-39746 , this is kinda ugly, even if it could be rewritten as container.exec("X").

It would be nice to have the ability to use .inside{...} not only on Image objects (source), but also on Container objects, to allow workflow like this:

docker.image('alpine').withRun { container ->

container.inside {
sh "X"
}
sh "Y"
container.inside {
sh "Z"
}
}

---
Originally reported by artalus, imported from: Implement .inside{} wrapper for Container object


  • status: Open
  • priority: Minor
  • component(s): docker-workflow-plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 1
  • imported: 2025-12-07

Raw content of original issue

Currently the workflow described in docs is something like this:



docker.image('alpine').inside {

sh 'X'
sh 'Y'
}


It does not address the situations when you need to:



  1. run X  in container

  2. run Y in host agent

  3. run Z in the same container, preserving changes from 1

The only solution to that, AFAIK, is something like this:



docker.image('alpine').withRun { container ->

sh "docker exec ${container.id} X"
sh "Y"
sh "docker exec ${container.id} Z"
}


As mentioned in JENKINS-39746 , this is kinda ugly, even if it could be rewritten as container.exec("X").

It would be nice to have the ability to use .inside{...} not only on Image objects (source), but also on Container objects, to allow workflow like this:



docker.image('alpine').withRun { container ->

container.inside {
sh "X"
}
sh "Y"
container.inside {
sh "Z"
}
}

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.