jenkinsci / jenkinsci/docker-workflow-plugin

[JENKINS-55306] Feature Request: Add exec/inner Method to Container Object

Open
#594 0 comments 0 reactions 0 assignees View on GitHub
component:docker-workflow-plugin enhancement imported-jira-issue pipeline priority:minor resolution:unresolved
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.

(Dupe GitHub Issue)

---
Originally reported by theory, imported from: Feature Request: Add exec/inner Method to Container Object


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

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.

(Dupe GitHub Issue)

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.