Last active
April 6, 2017 11:47
-
-
Save rpherrera/ea44f886ce65a55ebddb to your computer and use it in GitHub Desktop.
Wipeout all Docker Images found into an AWS account from ECR private registry, parsing results with jq.
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 -ex | |
# Warning: use with caution! Once ran, this script is going to wipeout all | |
# images that you own into your AWS ECR. | |
aws ecr describe-repositories | jq '.repositories[].repositoryName' | sed s/\"//g | while read repository_name; do | |
batch_delete_string='' | |
aws ecr list-images --repository-name "${repository_name}" | \ | |
jq '.imageIds[].imageTag' | while read image_tag; do | |
batch_delete_string="imageTag=${image_tag} " | |
done | |
if [ ! -z "${batch_delete_string}" ]; then | |
aws ecr batch-delete-image \ | |
--repository-name "${repository_name}" \ | |
--image-ids "${batch_delete_string}" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment