How to remove image from Azure Container Registry

Is there a way to remove only certain tags? I just found a way to delete the entire registry using REST / cli-acr

thanks

+13
source share
6 answers

We tightened the registry for the GA release later this month. We set aside all new features, focusing on performance, reliability and additional azure data centers, providing ACR in all public data centers by GA. We will provide removal of images and tags in a future version. We started using https://github.com/Azure/acr/ to track features and bugs. Delete here: https://github.com/Azure/acr/issues/33

Thanks for the feedback, Steve.

+6
source

You can use Azure CLI 2.0 to remove images from the repository with the specified tag:

az acr repository delete -n MyRegistry --repository MyRepository --tag MyTag

  • MyRegistry is the name of your Azure container registry
  • MyRepository is the name of the repository.
  • MyTag denotes the tag you want to remove.

You can also delete the entire repository by skipping --tag MyTag . More information on the az acr repository delete command can be found here: https://docs.microsoft.com/en-us/cli/azure/acr/repository#delete

+7
source

Here is a powershell script that removes all Azure Container registry tags except MyTag1 and MyTag2 tags:

 az acr repository show-tags -n MyRegistry --repository MyRepository | ConvertFrom-String | %{$_.P2 -replace "['",]",""} | where {$_ -notin "MyTag1","MyTag2" } | % {az acr repository delete -n MyRegistry --repository MyRepository --tag $_ --yes} 

It uses Azure CLI 2.0 .

+5
source

I had a similar problem when I wanted to delete historical images from the repository, since our quota reached 100%

I was able to do this using the following commands in Azure CLI 2.0. The process does the following: gets a list of tags, filters it with grep, and cleans it with sed before passing it to the delete command.

Get all tags for this repository.

 az acr repository show-tags -n [registry] --repository [repository] 

Get all tags that begin with a specific input and channel that will be passed to sed, which will remove the trailing comma

 grep \"[starts with] | sed 's/,*$//g' 

Using xargs, assign the output to the variable X and use this as a tag.

- manifest: Remove the manifest referenced by the tag. It also removes any associated layer data and all other tags that reference the manifest.

- yes -y: do not ask for confirmation.

 xargs -IX az acr repository delete -n [registry] --repository [repository] --tag X --manifest --yes 

eg. registry = myRegistry, repository = myRepo, I want to remove all tags that start with the tag 'test' (this will include test123, testing, etc.)

 az acr repository show-tags -n myRegistry --repository myRepo | grep \"test | sed 's/,*$//g' | xargs -IX az acr repository delete -n myRegistry --repository myRepo --tag X --manifest --yes 

More information can be found here Microsoft Azure Docs

+3
source

As an update today, we released a preview of several features, including the delete repository, individual logical Active Directory accounts, and Azure Web sites, Steve

+1
source

I tried all the teams, but none of them worked. I thought that they could be folded, so I went to my Azure portal and deleted my storage on my own. It is working

0
source

Source: https://habr.com/ru/post/1262230/


All Articles