jenkinsci / jenkinsci/docker-workflow-plugin
[JENKINS-55306] Feature Request: Add exec/inner Method to Container Object
- Dominant language
- Java
- Stars
- 527
- Forks
- 422
- Avg merge
- 10m
- Merged PRs (30d)
- 1
Description
Would be very handy to be able to connect to a running container from within a withRun block. I'm thinking it would behave exactly like inside(), except that it would run docker exec to run a command in the container. For example, if you needed to run a Postgres server with an extension installed, you could do it something like this:
script {
image('postgres:10').withRun('-p 5432:5432') { c ->
c.inside {
// Attached to the Postgres container.
sh "apt-get update"
sh "apt-get install hypopg"
}
// Do stuff that relies on Postgres with hypopg
}
}
I would think there would be plenty of use cases for spinning up a container and doing a bit of configuration on it before using a service it provides.
---
Originally reported by
theory, imported from: Feature Request: Add exec/inner Method to Container Object
Raw content of original issue
Would be very handy to be able to connect to a running container from within a withRun block. I'm thinking it would behave exactly like inside(), except that it would run docker exec to run a command in the container. For example, if you needed to run a Postgres server with an extension installed, you could do it something like this:
script {
image('postgres:10').withRun('-p 5432:5432') { c ->
c.inside {
// Attached to the Postgres container.
sh "apt-get update"
sh "apt-get install hypopg"
}
// Do stuff that relies on Postgres with hypopg
}
}I would think there would be plenty of use cases for spinning up a container and doing a bit of configuration on it before using a service it provides.
Contributor guide
Assessment
This issue has not been assessed yet.