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

Allow Image.run() etc to provide arguments to the container's command

    XMLWordPrintable

Details

    Description

      Currently it is possible with the docker-workflow-plugin to provide arguments to the docker run command. However these are inserted into the command line before the image name.
      There does not appear to be any way to specify arguments to appear after the image name; so currently it does not appear to be possible to provide arguments to the container's entrypoint (without creating a custom Dockerfile with those commands built in).

      e.g. the scenario I would like to achieve is the equivalent of this command line:

      docker run --link=mysql-container:mysql --link=mongo-container:mongo maven:3.3.3-jdk-7 clean install
      

      Currently I could run

      docker.image('maven:3.3.3-jdk-7').run("--link=${mysql.id}:mysql --link=${mongo.id}:mongo");
      

      which would take care of the arguments to docker, but would not pass 'clean install' arguments to the mvn command which is maven:3.3.3-jdk-7's entrypoint.

      Currently the only way I see to do this is to use 'sh' to run the docker command line, and not use the docker-workflow-plugin for this container.

      Attachments

        Issue Links

          Activity

            jglick Jesse Glick added a comment -
            docker.image('maven:3.3.3-jdk-7').inside("--link=${mysql.id}:mysql --link=${mongo.id}:mongo") {
              sh 'mvn clean install'
            }
            
            jglick Jesse Glick added a comment - docker.image( 'maven:3.3.3-jdk-7' ).inside( "--link=${mysql.id}:mysql --link=${mongo.id}:mongo" ) { sh 'mvn clean install' }

            Code changed in jenkins
            User: vfarcic
            Path:
            src/main/resources/org/jenkinsci/plugins/docker/workflow/Docker.groovy
            http://jenkins-ci.org/commit/docker-workflow-plugin/6a49c2225aa1d405179343a449590f84628a99da
            Log:
            JENKINS-33063

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: vfarcic Path: src/main/resources/org/jenkinsci/plugins/docker/workflow/Docker.groovy http://jenkins-ci.org/commit/docker-workflow-plugin/6a49c2225aa1d405179343a449590f84628a99da Log: JENKINS-33063

            Code changed in jenkins
            User: vfarcic
            Path:
            src/main/resources/org/jenkinsci/plugins/docker/workflow/DockerDSL/help.jelly
            http://jenkins-ci.org/commit/docker-workflow-plugin/8686313eabbb5b727607b0ef9b480ba64b7bdfbd
            Log:
            JENKINS-33063

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: vfarcic Path: src/main/resources/org/jenkinsci/plugins/docker/workflow/DockerDSL/help.jelly http://jenkins-ci.org/commit/docker-workflow-plugin/8686313eabbb5b727607b0ef9b480ba64b7bdfbd Log: JENKINS-33063

            Code changed in jenkins
            User: vfarcic
            Path:
            src/main/resources/org/jenkinsci/plugins/docker/workflow/Docker.groovy
            src/test/java/org/jenkinsci/plugins/docker/workflow/DockerDSLTest.java
            http://jenkins-ci.org/commit/docker-workflow-plugin/8ac95891861bd5405265f9b410b2e6d02fcbeaac
            Log:
            JENKINS-33063

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: vfarcic Path: src/main/resources/org/jenkinsci/plugins/docker/workflow/Docker.groovy src/test/java/org/jenkinsci/plugins/docker/workflow/DockerDSLTest.java http://jenkins-ci.org/commit/docker-workflow-plugin/8ac95891861bd5405265f9b410b2e6d02fcbeaac Log: JENKINS-33063

            Code changed in jenkins
            User: Jesse Glick
            Path:
            src/main/resources/org/jenkinsci/plugins/docker/workflow/Docker.groovy
            src/main/resources/org/jenkinsci/plugins/docker/workflow/DockerDSL/help.jelly
            src/test/java/org/jenkinsci/plugins/docker/workflow/DockerDSLTest.java
            http://jenkins-ci.org/commit/docker-workflow-plugin/153c70d5e863eb499b49d08d6992f3eff3ca586a
            Log:
            Merge pull request #37 from vfarcic/jenkins-33063

            [FIXED JENKINS-33063] Allow Image.run() to provide arguments to the container’s command

            Compare: https://github.com/jenkinsci/docker-workflow-plugin/compare/af5a6697a03f...153c70d5e863

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: src/main/resources/org/jenkinsci/plugins/docker/workflow/Docker.groovy src/main/resources/org/jenkinsci/plugins/docker/workflow/DockerDSL/help.jelly src/test/java/org/jenkinsci/plugins/docker/workflow/DockerDSLTest.java http://jenkins-ci.org/commit/docker-workflow-plugin/153c70d5e863eb499b49d08d6992f3eff3ca586a Log: Merge pull request #37 from vfarcic/jenkins-33063 [FIXED JENKINS-33063] Allow Image.run() to provide arguments to the container’s command Compare: https://github.com/jenkinsci/docker-workflow-plugin/compare/af5a6697a03f...153c70d5e863

            Code changed in jenkins
            User: Christian Alonso Chavez Ley
            Path:
            src/main/resources/org/jenkinsci/plugins/docker/workflow/Docker.groovy
            src/main/resources/org/jenkinsci/plugins/docker/workflow/DockerDSL/help.jelly
            src/test/java/org/jenkinsci/plugins/docker/workflow/DockerDSLTest.java
            http://jenkins-ci.org/commit/docker-workflow-plugin/770f038a72c3bbeb3fb173167546839d596aa129
            Log:
            JENKINS-36332 I would like to apply the same command parameter that's used in JENKINS-33063 to the "withRun" method so that I can clean up most of my containers as soon as they're finished.
            Given that I also kind of need this I just PR my take on the solution

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Christian Alonso Chavez Ley Path: src/main/resources/org/jenkinsci/plugins/docker/workflow/Docker.groovy src/main/resources/org/jenkinsci/plugins/docker/workflow/DockerDSL/help.jelly src/test/java/org/jenkinsci/plugins/docker/workflow/DockerDSLTest.java http://jenkins-ci.org/commit/docker-workflow-plugin/770f038a72c3bbeb3fb173167546839d596aa129 Log: JENKINS-36332 I would like to apply the same command parameter that's used in JENKINS-33063 to the "withRun" method so that I can clean up most of my containers as soon as they're finished. Given that I also kind of need this I just PR my take on the solution

            People

              vfarcic Viktor Farcic
              ntdaley Nicholas Daley
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: