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

doesn't work with remote docker servers

XMLWordPrintable

      Steps to reproduce:

      1. create new freestyle job
      2. enable Build inside a Docker container
      3. select Pull docker image from repository
      4. fill in Image id/tag (any image, e.g. ubuntu)
      5. click Advanced
      6. set Docker server URI to a remote docker server, e.g. tcp://192.168.2.14:2375
      7. add a Execute shell build step
      8. use anything as Command (e.g. env)
      9. save and run the job

      Expected outcome:
      Job succeeds, the command is run inside a remote container.

      Actual outcome:
      Job fails, console output contains:

      Started by user anonymous
      Building on master in workspace /var/jenkins_home/jobs/test-dock-env/workspace
      ...
      $ docker run --tty --detach --user 1000:1000 --workdir /var/jenkins_home/jobs/test-dock-env/workspace --volume /var/jenkins_home/jobs/test-dock-env/workspace:/var/jenkins_home/jobs/test-dock-env/workspace:rw --volume /tmp:/tmp:rw --env ******** ... ubuntu cat
      Docker container e93275a1a8256acd427bc21e1b9ab9850695198d231dad4792326e33b5d6d362 started to host the build
      [workspace] $ docker exec --tty e93275a1a8256acd427bc21e1b9ab9850695198d231dad4792326e33b5d6d362 /bin/sh -xe /tmp/hudson8942168893563194578.sh
      /bin/sh: 0: Can't open /tmp/hudson8942168893563194578.sh
      Build step 'Execute shell' marked build as failure

      Notes:
      Basically this can't work as the plugin assumes it can share source/scripts with the container using host bind mounts, which is not the case when using a remote docker server. Same situation arises when Jenkins itself is run in a container.

      I don't currently have a great idea on how to solve this.

      AFAICT the only concept that would work with remote dockers would be to stream the source/scripts to the container in a similar way as docker client streams context to the daemon during a build.

            ndeloof Nicolas De Loof
            jitakirin m jitakirin
            Votes:
            6 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved: