How to delete image from Azure Container Registry

2019-02-03 10:09发布

Is there a way to delete specific tags only? I only found a way to delete the whole registry using the REST/cli-acr

Thanks

6条回答
来,给爷笑一个
2楼-- · 2019-02-03 10:26

For current version

az acr repository untag --name [reponame] --image [imagename]:[tag]

查看更多
beautiful°
3楼-- · 2019-02-03 10:28

I had a similar problem where I wanted to remove historical images from the repository as our quota had reached 100%

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

Get all the tags for the given repository

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

Get all the tags that start with the specific input and pipe that 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 that as the tag.

--manifest : Delete the manifest referenced by a tag. This also deletes any associated layer data and all other tags referencing the manifest.

--yes -y : Do not prompt for confirmation.

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

e.g. registry = myRegistry, repository = myRepo, I want to remove all tags that start with the tagname 'test' ( this would include test123, testing etc )

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

More information can be found here Microsoft Azure Docs

查看更多
看我几分像从前
4楼-- · 2019-02-03 10:36

As an update, today we've released a preview of several features including repository delete, Individual Azure Active Directory Logins and Webhooks. Steve

查看更多
唯我独甜
5楼-- · 2019-02-03 10:42

You can use Azure CLI 2.0 to delete images from a repository with a given 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 delete.

You can also choose to delete the whole repository by omitting --tag MyTag. More information about the az acr repository delete command can be found here: https://docs.microsoft.com/en-us/cli/azure/acr/repository#delete

查看更多
Fickle 薄情
6楼-- · 2019-02-03 10:44

Here is a powershell script that deletes all Azure Container Registry tags except for tags MyTag1 and MyTag2:

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.

查看更多
女痞
7楼-- · 2019-02-03 10:47

We are hardening up the registry for our GA release later this month. We've deferred all new features while we focus on performance, reliability and additional azure data centers, delivering ACR across all public data centers by GA. We will provide deleting of images and tags in a future release. We're started to use https://github.com/Azure/acr/ to track features and bugs. Delete is captured here: https://github.com/Azure/acr/issues/33

Thanks for the feedback, Steve

查看更多
登录 后发表回答