azuredockeryamlazure-pipelinesacr

Pull and Push Docker Image task to ACR fails in Azure Devops Pipeline "unauthorized: Invalid clientid or client secret."


Pushing and pulling of image to Azure Container Registry task in Azure DevOps pipeline fails. When tried to pull or push from local system, there's no problem but when tried to do it using the Azure Devops pipeline it fails. Docker login was successful but it fails when I want to pull the image from the ACR with the following result:

**Error response from daemon: Head "***/a2/abcd/manifest/latest": unauthorized: Invalid clientid or client secret. 

##[error]Bash exited with code '1'.
##[debug]Processed: ##vso[task.issue type=error;]Bash exited with code '1'. 

I checked all the service connections in Az Devops, and they all look correctly configured. Checked the associated service principals as well if they have AcrPull and AcrPush permissions, all of them are in place. Just couldn't understand what's going wrong.

My Yaml looks like this:

trigger: none
schedules:
- cron: "0 0 0 * *"
  displayName: ****  *
  branches:
    include:
    - abcd
  always: true

pool:
  vmImage: 'ubuntu-latest'

variables:
- name: acrname
  value: *****.azurecr.io


stages:
- stage: abcd
  displayName: "pull images from acr"
  jobs:
  - job: abcdef
    displayName: "abcdef"
    pool:
      vmImage: ubuntu-latest
    steps:
      - task: Docker@2
        displayName: Login to ACR
        inputs:
          command: login
          containerRegistry: '*****.azurecr.io'
          

      - bash: |
            docker pull $(acrname)/abc-def:latest
            docker pull $(acrname)/igh-jkl:latest
        name: pull
        displayName: 'pull acr images'

Can anyone help?


Solution

    1. I had the same issue with the ACR service connection was expired. So I had to create a new service connection by using these steps.

    enter image description here

    1. Docker ID and Docker Password can be obtained from ACR --> Settings --> Access keys

    enter image description here

    1. Update your pipeline with this new service connection and you are good to go. Please rate if this solution helps you.