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

Parallel Docker pipeline

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Duplicate
    • Component/s: docker-workflow-plugin
    • Labels:
      None
    • Environment:
    • Similar Issues:

      Description

      docker withRun does not create separate containers when run within a parallel block. The output of the first step is shown in all steps.

      In the following example, "make frontend" fails and its output is repeated in the shell steps of both frontend and backend steps.

      node {
        def runCmd = { cmd ->
              docker.image("ubuntu:latest").withRun("-t -v /home/mn:/src/mn") { c ->
                  sh "docker exec ${c.id} ${cmd}"
              }
          }
        
        stage 'Build'
        runCmd 'npm install'
        parallel (
          "frontend": {
            runCmd "make frontend"
          },
          "backend": {
            runCmd "make backend"
          }
        )
      }
      

        Attachments

          Issue Links

            Activity

            Hide
            shauvik Shauvik Roy Choudhary added a comment - - edited

            The problem is that the plugin seems to start two docker containers but then sends subsequent commands to the same container.

            Here are the two docker run commands on the console.

            [frontend] + docker run -d -t -v /home/mn:/src/mn ubuntu:latest:latest
            [backend] + docker run -d -t -v /home/mn:/src/mn ubuntu:latest
            

            And here are the two docker exec commands:

            [frontend] + docker exec ce0926c89968932f4e5ff3a85fc39c16d435888c909c4e074cc1dd2af82e594b make frontend
            [backend] + docker exec ce0926c89968932f4e5ff3a85fc39c16d435888c909c4e074cc1dd2af82e594b make backend
            
            Show
            shauvik Shauvik Roy Choudhary added a comment - - edited The problem is that the plugin seems to start two docker containers but then sends subsequent commands to the same container. Here are the two docker run commands on the console. [frontend] + docker run -d -t -v /home/mn:/src/mn ubuntu:latest:latest [backend] + docker run -d -t -v /home/mn:/src/mn ubuntu:latest And here are the two docker exec commands: [frontend] + docker exec ce0926c89968932f4e5ff3a85fc39c16d435888c909c4e074cc1dd2af82e594b make frontend [backend] + docker exec ce0926c89968932f4e5ff3a85fc39c16d435888c909c4e074cc1dd2af82e594b make backend
            Hide
            shauvik Shauvik Roy Choudhary added a comment - - edited

            I think the docker-workflow-plugin is perhaps engineered to work with a single container at a time. Please close this issue if that's the direction. However, I think it should support multiple containers.

            Here is how I got my project to work by using the native docker commands by sh and not using this plugin:

            node {
              def runCmd = { cmd ->
                    sh "docker run --rm -v /home/mn:/src/mn ubuntu:latest ${cmd}"
                }
              
              stage 'Build'
              runCmd 'npm install'
              parallel (
                "frontend": {
                  runCmd "make frontend"
                },
                "backend": {
                  runCmd "make backend"
                }
              )
            }
            
            Show
            shauvik Shauvik Roy Choudhary added a comment - - edited I think the docker-workflow-plugin is perhaps engineered to work with a single container at a time. Please close this issue if that's the direction. However, I think it should support multiple containers. Here is how I got my project to work by using the native docker commands by sh and not using this plugin: node { def runCmd = { cmd -> sh "docker run --rm -v /home/mn:/src/mn ubuntu:latest ${cmd}" } stage 'Build' runCmd 'npm install' parallel ( "frontend" : { runCmd "make frontend" }, "backend" : { runCmd "make backend" } ) }

              People

              Assignee:
              jglick Jesse Glick
              Reporter:
              shauvik Shauvik Roy Choudhary
              Votes:
              3 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: