DEV Community

Ola Johansson
Ola Johansson

Posted on

Batch delete Docker images in a Azure Container Repository

This is mostly a note to self and i no credit whatsoever to myself. Info collected mainly from this SO question, but i had some issues with the info there, mainly stuff caused by changes to Azure CLI and some code formatting issues.

  1. Login with Azure CLI, az login
  2. Pick the correct subscription, az account set -s your_id
  3. Then run this command.
az acr repository show-tags -n YourRegistry --repository YourRepository | ConvertFrom-String | %{$_.P2 -replace "[`",]",""} | where {$_ -notin "4698a2ae296ed953890c1d61bfaf370deedfb29f" } | %{az acr repository delete -n YourRegistry --image YourRepository:$_ --yes}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)