Search code examples
dockerazure-devopsazure-pipelinesazure-container-registry

Unable to Push docker image to AzureContainer Registry from Azure Devops


Docker image has been created usefully

Successfully built 188e6513fb56 Successfully tagged satyam-hello:20210210.24

My docker push Image task is not working

  • task: Docker@2 displayName: 'Push Container Image' inputs: containerRegistry: '$(SubscriptionEndpoint)' #the ACR service connection created above repository: '$(acrHostName)' imageName: '$(imageName)' command: push tags: '$(tags)'
    ====== below is the error

The push refers to repository [.azurecr.io/.azurecr.io] An image does not exist locally with the tag: .azurecr.io/.azurecr.io ##[error]An image does not exist locally with the tag: .azurecr.io/.azurecr.io ##[error]The process '/usr/bin/docker' failed with exit code 1


Solution

  • The property azureSubscriptionEndpoint doesnot exist for Docker task. See docker task document.

    If you use Docker task to push your image to ACR. You need to create a ACR service connection.

    Go to Project settings-->Service connection-->New Service connection-->Docker Registry -->Azure Container Registry/Others. See below screenshot.

    enter image description here

    As above error indicated, you also need to specify the repository property for the Docker task. See below example:

    - task: Docker@2
      displayName: push
      inputs:
        containerRegistry: ACR-ServiceConnection  #the ACR service connection created above
        repository: MyRepository #the repository in your ACR
        command: push
    

    Update:

    There is no imageName parameter for docker task. If the image is satyam-hello:20210210.24. You should configure docker task as below:

    - task: Docker@2
      displayName: push
      inputs:
        containerRegistry: ACR-ServiceConnection #$(SubscriptionEndpoint)
        repository: 'satyam-hello' #$(imageName)
        command: push
        tags: 20210210.24  #$(tags)