20

I see you can untag an image in an Azure Container Registry

https://learn.microsoft.com/en-us/cli/azure/acr/repository?view=azure-cli-latest#az-acr-repository-show-manifests

But how do you add a tag?

3 Answers 3

39

You can use import command to import the image in the same repository:

az acr import --name myacr --source myacr.azurecr.io/myimage:latest --image myimage:retagged --force
3
  • 1
    This will fail if there is an existing tag already in the repository. with the following error"Tag {yourtag} already exists in target registry.". here is the documentation: learn.microsoft.com/en-us/cli/azure/… i think the import command is used to "Imports an image to an Azure Container Registry from another Container Registry. " Commented Aug 10, 2020 at 18:39
  • I have posted my solution to the problem Commented Aug 10, 2020 at 19:21
  • 11
    this actually works - there is now a --force flag which allows you to overwrite existing tags. Commented Oct 29, 2020 at 17:03
9

As far as I know. There is no Azure CLI command to create a tag for the images directly. If you want to add a tag for the image, you just can use the docker command docker tag to add the tag and then push the image to Azure Container Registry.

When you create the image through the build task, it also will lead to the tag adding. Take a look at this.

4

I had overwrite an existing tag with a latest build inside a release pipeline. So I could not do a build step since its inside a release pipeline. This is my solution hope this helps someone:

This is my release pipeline: Step 1

task 1: Docker CLI installer

task 2: Docker Task - with login command(log into the ACR)

task 3: Powershell script: which runs these commands (in my case )

 $sourceImage= "acrloginserver/repository:old-tag";
 $newtag= "acrloginserver/repository:latest-tag"
 docker pull $sourceImage
 docker tag $sourceImage $newtag
 docker push $newtag`




 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.