Skip to content

Instantly share code, notes, and snippets.

View zeg-io's full-sized avatar

Tony zeg-io

  • Zetta Engineering Group
  • Dallas, TX
View GitHub Profile
@zeg-io
zeg-io / dk-clean.sh
Created May 18, 2017 01:03
Clean all Docker images older than 4 weeks
oldContainers="$(docker ps -f "status=exited" | grep -E 'Exited \(.*\) [5-9] h|Exited \(.*\) \d\d h' | awk '{ print $1 }')"
echo -e -n "\nRemoving containers older than 4 hours"
if [ "$oldContainers" != "" ]; then
echo ""
docker rm $oldContainers
else
echo "...none found."
fi