Skip to content

Instantly share code, notes, and snippets.

@spkellydev
Created April 26, 2019 21:05
Show Gist options
  • Save spkellydev/7fcf48852d5e76cbd240bca1509bccbd to your computer and use it in GitHub Desktop.
Save spkellydev/7fcf48852d5e76cbd240bca1509bccbd to your computer and use it in GitHub Desktop.
Prune all docker images for a specific repo where the tag does not equal "latest"
docker images --format 'table {{.Repository}}\t{{.Tag}}\t{{.ID}}' \ # custom docker ps
| grep repository/image \ # get the repository
| grep -v latest \ # get all repositories which are not tagged latest
| awk '{print $3}' \ # get the ID (third column) of the image
| xargs docker rmi # delete image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment