Created
October 20, 2019 21:09
-
-
Save ederparaiso/7b06f89303cabe71d9940a5095168114 to your computer and use it in GitHub Desktop.
Purge container images in Azure Container Registry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# WARNING! This script deletes data! | |
# Purge old images retaining configured amount of tags. Tag latest will be always preserved. | |
REGISTRY=your_registry | |
REPOSITORY=your_repository | |
HISTORY_SIZE=amount_of_tags_to_be_remain | |
az acr repository show-tags -n $REGISTRY --repository $REPOSITORY --orderby time_desc --query "[?@ != 'latest'] | [$HISTORY_SIZE:]" -o tsv \ | |
| xargs --replace=tag --verbose az acr repository delete -n $REGISTRY --image $REPOSITORY:tag --yes | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment