-
New Feature
-
Resolution: Unresolved
-
Minor
-
None
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:
- run X in container
- run Y in host agent
- 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" } }