Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-68955

Implement .inside{} wrapper for Container object

XMLWordPrintable

      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"
        }
      }

            Unassigned Unassigned
            artalus Artalus S.
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: