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

Setting Docker Workflow creds globally breaks agents using other registries

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • docker-workflow-plugin
    • None
    • Jenkins: 2.492.2
      Docker Commons Plugin Version 451.vd12c371eeeb_3
      Docker Pipeline Version 611.v16e84da_6d3ff

      Overview

      When setting Docker Credentials globally (i.e. Manage Jenkins -> System -> "Declarative Pipeline (Docker)" -> "Registry credentials") with docker agent pipeline configuration it tries to pull the incorrect image.

      Output

      [Pipeline] withDockerRegistry
      $ docker login -u username -p ******** https://index.docker.io/v1/
      WARNING! Using --password via the CLI is insecure. Use --password-stdin.
      WARNING! Your password will be stored unencrypted in /home/jenkins/workspace/REDACTED/config.json.
      Configure a credential helper to remove this warning. See
      https://docs.docker.com/engine/reference/commandline/login/#credentials-store
      
      Login Succeeded
      [Pipeline] {
      [Pipeline] isUnix
      [Pipeline] withEnv
      [Pipeline] {
      [Pipeline] sh
      + docker inspect -f . public.ecr.aws/docker/library/ruby:3
      
      Error: No such object: public.ecr.aws/docker/library/ruby:3
      [Pipeline] sh
      + docker inspect -f . index.docker.io/public.ecr.aws/docker/library/ruby:3
      
      Error: No such object: index.docker.io/public.ecr.aws/docker/library/ruby:3
      [Pipeline] isUnix
      [Pipeline] withEnv
      [Pipeline]
      
      { [Pipeline] sh + docker pull index.docker.io/public.ecr.aws/docker/library/ruby:3 Error response from daemon: Head "https://public.ecr.aws/v2/docker/library/ruby/manifests/3": denied: Not Authorized [Pipeline] }
      

       

      Reproduction

      I have been able to reproduce with the latest Jenkins version and plugins listed above.

      1. Setup a Jenkins instance with version and plugins as above
      2. Create a Pipeline with this content:
        pipeline {
          agent any
          stages {
            stage('AWS Public Mirror') {
              agent {
                docker {
                  image 'public.ecr.aws/docker/library/ruby:3'
                  reuseNode true
                }
              }
              steps {
                sh 'echo AWS Public Mirror'
              }
            }
          }
        }
      1. Run pipeline, it will succeed
      2. docker rmi the image it fetched
      3. Add some DockerHub Creds
      4. Configure Jenkins to use those credentials globally: Manage Jenkins -> System -> "Declarative Pipeline (Docker)" -> "Registry credentials"
      5. Re-Run the pipeline, it will fail with: denied: Not Authorized [Pipeline]

       

      Final thoughts

            Unassigned Unassigned
            seanhood Sean
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: