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

docker.withRegistry fails to login

XMLWordPrintable

      In my Jenkins pipeline I had my docker plugin configured as such:

      docker.withRegistry('https://registry.hub.docker.com', 'my-docker-hub-cred') {
          sh "docker load -i ${WORKSPACE}/my-image.tar"   
          docker.image("my-image:latest").push()
      } 

       

      It worked fine so far. Notice the URL I used for the `withRegistry` call (https://registry.hub.docker.com).
      In order to support some multi-arch images I had to introduce some different docker commands such as `docker manifest`

      So it ended up like this:

      docker.withRegistry('', 'my-docker-hub-cred') 
          sh "docker load -i ${WORKSPACE}/my-image-amd64.tar"
          sh "docker load -i ${WORKSPACE}/my-image-arm64.tar"
      
          docker.image("my-image:latest-amd64").push() 
          docker.image("my-image:latest-arm64").push() 
      
          sh "docker manifest create my-image:latest --amend my-image:latest-amd64 --amend my-image:latest-arm64"                        
          sh "docker manifest push my-image:latest"
      
      } 

       

      If you notice, I've had to remove the URL `https://registry.hub.docker.com` from the Docker plugin withRegistry method. Otherwise I get the following error every time I try to push the images:

      22:51:16  denied: requested access to the resource is denied
      22:51:16  unauthorized: authentication required

      I tried out by using the following URLs but none of them actually worked:

            csanchez Carlos Sanchez
            afalhambra Antonio
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: