Batch delete Docker images in a Azure Container Repository

olaj

Ola Johansson

Posted on July 7, 2022

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.

https://stackoverflow.com/questions/41446962/how-to-delete-image-from-azure-container-registry

  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
💖 đŸ’Ș 🙅 đŸš©
olaj
Ola Johansson

Posted on July 7, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related