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

Ability to run Docker container in foreground mode (no detached)

    XMLWordPrintable

Details

    Description

      Currently we can only use Pipeline Docker Plugin to run container in detached mode.
      withRun(), run(), inside() methods add "-d" option in docker run command line.
      We should be able to run container in foreground mode (not detached).
      Currently we want to run CloudSlang flow through docker image and see the flow output in Jenkins:

      docker run --rm cloudslang/cloudslang run --f ../content/io/cloudslang/base/print/print_text.sl --i text=first_flow

      We are not able to see the output of the command since docker pipeline step is run in detached mode and exit when the CloudSlang flow terminate.

      Attachments

        Activity

          aaroncraig Aaron Craig added a comment -

           

          This is an issue for us as well.  We're running a Node test suite inside a docker container, so something like:

          ```

          ...

          RUN npm install

          CMD ["node", "test"]

          ```

          The build passes even though the tests fail, and I'm assuming this is due to the detached state of the container.

          aaroncraig Aaron Craig added a comment -   This is an issue for us as well.  We're running a Node test suite inside a docker container, so something like: ``` ... RUN npm install CMD ["node", "test"] ``` The build passes even though the tests fail, and I'm assuming this is due to the detached state of the container.
          vlastimil_dolejs Vlastimil Dolejš added a comment - - edited

          Hi, as a workaround I was able to run docker like this:

          docker.node {
              docker.script.sh(script: "docker run -e SOME_ENV --rm docker/image-name command", returnStdout: false)
          }

          I have found this code in the sources of the plugin. I'm not sure if it is safe to touch these internals, but it worked for me.

          vlastimil_dolejs Vlastimil Dolejš added a comment - - edited Hi, as a workaround I was able to run docker like this: docker.node {     docker.script.sh(script: "docker run -e SOME_ENV --rm docker/image-name command", returnStdout: false) } I have found this code in the sources of the plugin. I'm not sure if it is safe to touch these internals, but it worked for me.

          Please review this:
          https://github.com/jenkinsci/docker-workflow-plugin/pull/196

          comments are welcomed.

          aduprat Antoine Duprat added a comment - Please review this: https://github.com/jenkinsci/docker-workflow-plugin/pull/196 comments are welcomed.

          People

            aduprat Antoine Duprat
            lautou Laurent TOURREAU
            Votes:
            4 Vote for this issue
            Watchers:
            10 Start watching this issue

            Dates

              Created:
              Updated: