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

Building an image with a custom registry overwrites environment variables

XMLWordPrintable

    • Docker Commons Plugin 1.15

      We are using a Jenkinsfile-based pipeline to build an image using a private docker registry. The corporate proxy has been configured in the docker config, which is then passed via environment variables (HTTP(S)_PROXY). It seems that specifying a private docker registry overwrites the proxy settings, supplied by the docker daemon, resulting in the following error message:

      fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
      [91mERROR: http://dl-cdn.alpinelinux.org/alpine/v3.8/main: DNS lookup error
      WARNING: Ignoring APKINDEX.adfa7ceb.tar.gz: No such file or directory
      

      The issue can be reproduced with the following simple Jenkinsfile (in order to test it you would need access to a private docker registry and be behind a corporate proxy):
       

      node('docker') {
          stage("first") {
              sh 'echo FROM alpine > Dockerfile'
              sh 'echo RUN printenv >> Dockerfile'
              sh 'echo RUN apk add bash >> Dockerfile'
              
              //docker.withRegistry('https://registry.hub.docker.com') {
              docker.withRegistry('https://artifactory-url-here', 'credentials-id-here') {
                  docker.build('test')
              }
          }
      }
      

      This is the output when using docker hub:

      HOSTNAME=f85fb49b6a51
      SHLVL=1
      HOME=/root
      PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
      PWD=/
      

      And this is the output when using a private docker registry:

      HOSTNAME=b2c35a88bf3e
      SHLVL=1
      HOME=/root
      PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
      PWD=/
      NO_PROXY=xxxxx
      HTTPS_PROXY=xxxxxx
      HTTP_PROXY=xxxxxx
      

            Unassigned Unassigned
            kvalev Krassimir Valev
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: