Uploaded image for project: 'Infrastructure'
  1. Infrastructure
  2. INFRA-2201

When running a swarn-client docker image docker.inside() fails

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Not A Defect
    • Component/s: docker
    • Labels:
    • Environment:
      openjdk 11 (11.0.4+11-post-Debian-1deb10u1)
      jenkins:lts (all plugins up to date as of 2019-08-02)
      jenkins-swarm (newest as of 2019-08-02)
    • Similar Issues:

      Description

      When running {docker}.inside(){ sh .... }, the process (sh/docker plugin) hangs

       
       

      script {
           docker.withRegistry("https://${dockerRepository}", "nexus-upload") {
              def img = docker.image("${imageName}:${imageLabel}")
               img.pull()
               img.inside("-u root:root") {
                  echo "Inside container"
                  sh 'echo "Inside shell";'
               }
               // sh "docker run --rm ${imageName}:${imageLabel} echo 'inside shell';"
      }
      }

       
      Gives following output:
       

      08:52:53 Login Succeeded
      08:52:53 [Pipeline] {
      08:52:53 [Pipeline] sh
      08:52:54 + docker pull ****/xxx:latest
      08:52:54 latest: Pulling from xxx
      08:52:54 Digest: sha256:076b2b1038d70bb5b3fa9ba5cd65e913864fe101148631b3af2f7891d9cab741
      08:52:54 Status: Image is up to date for ****/xxx:latest
      08:52:54 ****/xxx:latest
      08:52:54\ [Pipeline] sh
      08:52:54 + docker inspect -f . xxx:latest
      08:52:54 .
      08:52:54 [Pipeline] withDockerContainer
      08:52:54 98335e67ed9d seems to be running inside container 98335e67ed9df8f176329ebd5b3439693c3ac9993315562a10fe682280659b6a
      08:52:54 but /var/lib/jenkins/workspace/XXX_master could not be found among []
      08:52:54 but /var/lib/jenkins/workspace/XXX_master@tmp could not be found among []
      08:52:54 $ docker run -t -d -u 999:999 -u root:root -w /var/lib/jenkins/workspace/XXX_master -v /var/lib/jenkins/workspace/XXX_master:/var/lib/jenkins/workspace/XXX_master:rw,z -v /var/lib/jenkins/workspace/XXX_master@tmp:/var/lib/jenkins/workspace/XXX@tmp:rw,z -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** xxx:latest cat
      08:52:55 $ docker top 23c95c027e83231f00c6891ce8433b3de66ecd949c28205f750a4b4d765b0b7f -eo pid,comm
      08:53:00 [Pipeline] {
      08:53:00 [Pipeline] echo
      08:53:00 inside container
      08:53:00 [Pipeline] sh
      08:57:09 Aborted by yyyy
      08:57:10 Sending interrupt signal to process

       

      On the master host dockerd is exposed with tcp://0.0.0.0/.

      Running the  commented docker inside a sh '...' line works fine.

      It looks like it gets confused when starting a container (on the same dockerd) from inside a container,

      the jenkins-swarm-image is build with:
       

      FROM debian:latest

      RUN sed -i 's#http://[^/]*#http://debian.example.com#' /etc/apt/sources.list
      RUN (for l in '#!/bin/bash -e' 'trap "rm -rf /var/lib/apt/list/*" EXIT' 'export DEBIAN_FRONTEND=noninteractive' 'apt-get update && apt-get install -qy --no-install-recommends "$@"' 'apt-get auto-clean' 'apt-get clean'; do echo $l; done) > /sbin/apt-install && chmod +x /sbin/apt-install
      RUN apt-install apt-transport-https ca-certificates curl gnupg2 software-properties-common less vim
      RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - && echo "deb https://download.docker.com/linux/debian $(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list
      RUN apt-install docker-ce-cli
      RUN apt-install openjdk-11-jdk maven git
      RUN useradd -r jenkins -m -d /var/lib/jenkins
      RUN mvn dependency:get -DremoteRepositories=https://repo.jenkins-ci.org/public/ -Dartifact=org.jenkins-ci.plugins:swarm-client:LATEST && cp $(find ~/.m2/repository/org/jenkins-ci/plugins/swarm-client -name swarm-client*.jar) /usr/local/lib/swarm-client.jar && rm -rf ~/.m2
      USER jenkins
      ENV \
      DOCKER_HOST=tcp://exmple.com/ \
      JENKINS_USER=swarm \
      JENKINS_PASSWORD=swarm \
      JENKINS_URL=https://exmple.com/ \
      JENKINS_LABELS="docker java" \
      EXECUTORS=3
      CMD [ "bash", "-xc", "env -i DOCKER_HOST=\"$DOCKER_HOST\" HOME=\"$HOME\" HOSTNAME=\"$HOSTNAME\" PATH=\"$PATH\" java -jar /usr/local/lib/swarm-client.jar -username \"$JENKINS_USER\" -password \"$JENKINS_PASSWORD\" -master \"$JENKINS_URL\" -labels \"$JENKINS_LABELS\" -name \"$(hostname)\" -fsroot \"$HOME\" -executors \"$EXECUTORS\" -disableClientsUniqueId" ]

       

       
      Ps. how can it be so difficult to insert log/code into a bug report and have it reproduced just vaguely familiar when published
       

        Attachments

          Activity

          Hide
          rtyler R. Tyler Croy added a comment -

          The INFRA project is for Jenkins project infrastructure issues only

          Show
          rtyler R. Tyler Croy added a comment - The INFRA project is for Jenkins project infrastructure issues only

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            bogeskov Morten Bøgeskov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: