Azure Container Registry ACR How to add tag to image?
Asked Answered
L

3

17

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?

Lanoralanose answered 14/11, 2018 at 22:29 Comment(0)
W
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.

Weakwilled answered 15/11, 2018 at 2:8 Comment(0)
C
34

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
Camellia answered 16/6, 2020 at 13:55 Comment(3)
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. "Bathsheba
I have posted my solution to the problemBathsheba
this actually works - there is now a --force flag which allows you to overwrite existing tags.Jural
W
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.

Weakwilled answered 15/11, 2018 at 2:8 Comment(0)
B
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`




 
Bathsheba answered 10/8, 2020 at 19:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.