15 lines
453 B
Bash
Executable file
15 lines
453 B
Bash
Executable file
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
if [ -e "${HOME}/bin/script_framework.sh" ]; then
|
|
source "${HOME}/bin/script_framework.sh"
|
|
else
|
|
function step() { echo $@; }
|
|
fi
|
|
|
|
step "Removing containers created / exited >= ~1h ago..."
|
|
CONTAINERS=$(docker ps -a | gawk '/(hours?|days?|weeks?|months?) ago\s+(Created|Exited)/{ print $1 }' | xargs)
|
|
[ -n "${CONTAINERS}" ] && docker rm ${CONTAINERS}
|
|
|
|
step "Removing unused and dangling images..."
|
|
docker image prune -a -f
|