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

Nested agent try to fetch the image from top defined agent registry instead of docker hub

      When you run a nested agent (let's call it 2nd agent) in the pipeline definition, it is being pulled from the 1st agent's (defined on top of pipeline) registry when no registry is specified on the 2nd (which should mean the official docker hub).

      Steps to reproduce:

      1. Run your Jenkins master, and assure the place you're gonna run the pipeline has Docker installed.
      2. Create a pipeline like this:
      ```groovy
      pipeline {
          agent {
              docker 

      {              registryUrl 'https://mirror.gcr.io'             image 'library/docker'             args '-v /var/run/docker.sock:/var/run/docker.sock'         }

          }
          stages {
              stage('Docker on Docker') {
                  agent {
                      docker 

      {                      // Should fetch from docker hub, right? It tries to fetch from the https://mirror.gcr.io instead.                     image 'alpine'                 }

                  }
                  steps 

      {                  sh 'echo hi'             }

              }
          }
      }
      ```
      3. Run, and you'll get something like this:
      ```log
      [Pipeline] {
      [Pipeline] stage
      [Pipeline] { (Docker on Docker)
      [Pipeline] getContext
      [Pipeline] isUnix
      [Pipeline] sh
      + docker inspect -f . alpine

      Error: No such object: alpine
      15:45:40.417159 durable_task_monitor.go:63: exit status 1
      [Pipeline] isUnix
      [Pipeline] sh
      + docker inspect -f . mirror.gcr.io/alpine

      Error: No such object: mirror.gcr.io/alpine
      15:45:40.704922 durable_task_monitor.go:63: exit status 1
      [Pipeline] isUnix
      [Pipeline] sh
      + docker pull mirror.gcr.io/alpine
      Using default tag: latest
      Error response from daemon: manifest for mirror.gcr.io/alpine:latest not found: manifest unknown: Failed to fetch "latest" from request "/v2/alpine/manifests/latest".
      15:45:41.467742 durable_task_monitor.go:63: exit status 1
      ```

      As you can see it tries to pull from mirror.gcr.io instead of the docker hub.

          [JENKINS-59976] Nested agent try to fetch the image from top defined agent registry instead of docker hub

          Felipe Santos created issue -
          Felipe Santos made changes -
          Epic Link New: JENKINS-45381 [ 183541 ]
          Felipe Santos made changes -
          Summary Original: Nested agent try to fetch the image from top defined registry instead of docker hub New: Nested agent try to fetch the image from top defined agent registry instead of docker hub
          Felipe Santos made changes -
          Attachment New: consoleText.txt [ 49344 ]

          Felipe Santos added a comment -

          This is a workaround which can be used for now:

          Specify the registry on the 2nd agent
          agent {
              docker 

          {          registryUrl 'https://docker.io'         image 'alpine'     }

          }

          Felipe Santos added a comment - This is a workaround which can be used for now: Specify the registry on the 2nd agent agent {     docker  {          registryUrl 'https://docker.io'         image 'alpine'     } }
          Felipe Santos made changes -
          Description Original: When you run a nested agent (let's call it 2nd agent) in the pipeline definition, it is being pulled from the 1st agent (agent defined on top of pipeline) when no registry is specified (which should mean the official docker hub).

          Steps to reproduce:

          1. Run your Jenkins master, and assure the place you're gonna run the pipeline has Docker installed.
          2. Create a pipeline like this:
          ```groovy
          pipeline {
              agent {
                  docker { 
                      registryUrl 'https://mirror.gcr.io'
                      image 'library/docker'
                      args '-v /var/run/docker.sock:/var/run/docker.sock'
                  }
              }
              stages {
                  stage('Docker on Docker') {
                      agent {
                          docker { 
                              // Should fetch from docker hub, right? It tries to fetch from the https://mirror.gcr.io instead.
                              image 'alpine'
                          }
                      }
                      steps { 
                          sh 'echo hi'
                      }
                  }
              }
          }
          ```
          3. Run, and you'll get something like this:
          ```log
          [Pipeline] {
          [Pipeline] stage
          [Pipeline] { (Docker on Docker)
          [Pipeline] getContext
          [Pipeline] isUnix
          [Pipeline] sh
          + docker inspect -f . alpine

          Error: No such object: alpine
          15:45:40.417159 durable_task_monitor.go:63: exit status 1
          [Pipeline] isUnix
          [Pipeline] sh
          + docker inspect -f . mirror.gcr.io/alpine

          Error: No such object: mirror.gcr.io/alpine
          15:45:40.704922 durable_task_monitor.go:63: exit status 1
          [Pipeline] isUnix
          [Pipeline] sh
          + docker pull mirror.gcr.io/alpine
          Using default tag: latest
          Error response from daemon: manifest for mirror.gcr.io/alpine:latest not found: manifest unknown: Failed to fetch "latest" from request "/v2/alpine/manifests/latest".
          15:45:41.467742 durable_task_monitor.go:63: exit status 1
          ```

          As you can see it tries to pull from mirror.gcr.io instead of the docker hub.
          New: When you run a nested agent (let's call it 2nd agent) in the pipeline definition, it is being pulled from the 1st agent's (defined on top of pipeline) registry when no registry is specified on the 2nd (which should mean the official docker hub).

          Steps to reproduce:

          1. Run your Jenkins master, and assure the place you're gonna run the pipeline has Docker installed.
           2. Create a pipeline like this:
           ```groovy
           pipeline {
               agent {
                   docker 

          {              registryUrl 'https://mirror.gcr.io'             image 'library/docker'             args '-v /var/run/docker.sock:/var/run/docker.sock'         }

              }
               stages {
                   stage('Docker on Docker') {
                       agent {
                           docker 

          {                      // Should fetch from docker hub, right? It tries to fetch from the https://mirror.gcr.io instead.                     image 'alpine'                 }

                      }
                       steps 

          {                  sh 'echo hi'             }

                  }
               }
           }
           ```
           3. Run, and you'll get something like this:
           ```log
           [Pipeline] {
           [Pipeline] stage
           [Pipeline] { (Docker on Docker)
           [Pipeline] getContext
           [Pipeline] isUnix
           [Pipeline] sh
           + docker inspect -f . alpine

          Error: No such object: alpine
           15:45:40.417159 durable_task_monitor.go:63: exit status 1
           [Pipeline] isUnix
           [Pipeline] sh
           + docker inspect -f . mirror.gcr.io/alpine

          Error: No such object: mirror.gcr.io/alpine
           15:45:40.704922 durable_task_monitor.go:63: exit status 1
           [Pipeline] isUnix
           [Pipeline] sh
           + docker pull mirror.gcr.io/alpine
           Using default tag: latest
           Error response from daemon: manifest for mirror.gcr.io/alpine:latest not found: manifest unknown: Failed to fetch "latest" from request "/v2/alpine/manifests/latest".
           15:45:41.467742 durable_task_monitor.go:63: exit status 1
           ```

          As you can see it tries to pull from mirror.gcr.io instead of the docker hub.
          Felipe Santos made changes -
          Attachment New: Jenkins.png [ 49345 ]

          Felipe Santos added a comment -

          Another workaround is to manually set the default Docker registry URL to https://docker.io under Manage Jenkins -> Configure System > Pipeline Model Definition, despite it says the blank works the same. See attached pic.

          Felipe Santos added a comment - Another workaround is to manually set the default Docker registry URL to https://docker.io  under Manage Jenkins -> Configure System > Pipeline Model Definition, despite it says the blank works the same. See attached pic.
          Andrew Bayer made changes -
          Assignee Original: Andrew Bayer [ abayer ]

            Unassigned Unassigned
            felipecassiors Felipe Santos
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: