How to delete image from Azure Container Registry

后端 未结 8 935
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-29 09:13

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

8条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-29 09:31

    Following command helps while deleting specific images following a name or search pattern :-

    az acr repository show-manifests -n myRegistryName --repository myRepositoryName --query '[].tags[0]' -o yaml | grep 'mySearchPattern' | sed 's/- /az acr repository delete --name myRegistryName --yes --image myRepositoryName:/g'
    

    My use case was to delete all Container Registeries which were created before August in 2020 so I copied the output of the following command and then executed them, as my manifest names had creation Date like DDMMYYYY-HHMM:-

    az acr repository show-manifests -n myRegistryName --repository myRepositoryName --query '[].tags[0]' -o yaml | grep '[0-7]2020-' | sed 's/- /az acr repository delete --name myRegistryName --yes --image myRepositoryName:/g'
    

    Reference: Microsoft ACR CLI

提交回复
热议问题