2016-07-21 13:48:49 +00:00
|
|
|
#!/bin/bash
|
2018-01-13 18:05:15 +00:00
|
|
|
set -euo pipefail
|
2016-07-21 13:48:49 +00:00
|
|
|
|
2018-01-13 18:05:15 +00:00
|
|
|
if [ -e "${HOME}/bin/script_framework.sh" ]; then
|
2018-07-08 19:47:27 +00:00
|
|
|
source "${HOME}/bin/script_framework.sh"
|
2018-01-13 18:05:15 +00:00
|
|
|
else
|
2018-07-08 19:47:27 +00:00
|
|
|
function step() { echo $@; }
|
2018-01-13 18:05:15 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
step "Removing containers created / exited >= ~1h ago..."
|
2018-07-08 19:47:27 +00:00
|
|
|
CONTAINERS=$(docker ps -a | gawk '/(hours?|days?|weeks?|months?) ago\s+(Created|Exited)/{ print $1 }' | xargs)
|
2018-01-13 18:05:15 +00:00
|
|
|
[ -n "${CONTAINERS}" ] && docker rm ${CONTAINERS}
|
|
|
|
|
2018-07-08 19:47:27 +00:00
|
|
|
step "Removing unused and dangling images..."
|
|
|
|
docker image prune -a -f
|