I need to build a docker image in Azure pipeline and push it to different ACRs. I can successfully push an image to the same ACR where it was buid, but when pushing to other ACR the push task fails with "An image does not exist locally with the tag" error.
- task: Docker@2
displayName: Build
inputs:
command: build
containerRegistry: REGISTRY1
repository: $(ACR_URL1)/test
tags: |
latest
# This push succeeds
- task: Docker@2
displayName: Push to ACR1
inputs:
command: push
containerRegistry: REGISTRY1
repository: $(ACR_URL1)/test
tags: |
latest
# This push fails
- task: Docker@2
displayName: Push to ACR2
inputs:
command: push
containerRegistry: REGISTRY2
repository: $(ACR_URL2)/test
tags: |
latest
The obvious workaround is to separately build an image on each ACR, but it is far from optimal since the build takes almost an hour. And unfortunately, I cannot use docker command line, only DevOps tasks (like Docker@2).