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

image.inside() does not respect docker.withServer() settings

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • docker-workflow-plugin
    • None
    • CloudBees Docker Pipeline 1.9
      Jenkins is running inside a docker container
      Docker Server is accessed via tcp (TLS)
      Jenkins home directory is mounted via volume

      Using image.inside() inside docker.withServer() does fails with the following error:

      [Pipeline] withDockerContainer
      $ docker run -t -d -u 1000:1000 -w "/var/jenkins_home/workspace/Utility Jobs/copy-schema" -v "/var/jenkins_home/workspace/Utility Jobs/copy-schema:/var/jenkins_home/workspace/Utility Jobs/copy-schema:rw" -v "/var/jenkins_home/workspace/Utility Jobs/copy-schema@tmp:/var/jenkins_home/workspace/Utility Jobs/copy-schema@tmp:rw" -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** --entrypoint cat dockerimage
      [Pipeline] {
      [Pipeline] sh
      [copy-schema] Running shell script
      sh: /var/jenkins_home/workspace/Utility Jobs/copy-schema@tmp/durable-f8d02fd0/pid: No such file or directory
      sh: /var/jenkins_home/workspace/Utility Jobs/copy-schema@tmp/durable-f8d02fd0/jenkins-log.txt: No such file or directory
      sh: /var/jenkins_home/workspace/Utility Jobs/copy-schema@tmp/durable-f8d02fd0/jenkins-result.txt: No such file or directory
      [Pipeline] }
      $ docker stop --time=1 d1f1d8173fcc89762825aeee7019aa24e88e4f9c87c08036083118cd4c708f26
      $ docker rm -f d1f1d8173fcc89762825aeee7019aa24e88e4f9c87c08036083118cd4c708f26
      [Pipeline] // withDockerContainer
      

      I've debugged my Jenkins instance and it turns out that the docker inspect calls inside org.jenkinsci.plugins.docker.workflow.WithContainerStep.Execution.start() fail silently because the docker client can't connect to the docker host. The reason seems to be that the call to org.jenkinsci.plugins.docker.workflow.client.DockerClient.getVolumes(EnvVars, String) uses envHost which does not contain the environment variables set by withServer(). If I pass in all environment variables ( env) the call succeeds and the inside() step succeeds as well (the volume from the master is reused using --volumes-from).

      I'm not sure about the other implications of passing in env instead of envHost.

            Unassigned Unassigned
            cfraenkel Christian Fraenkel
            Votes:
            2 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: