Prune dangling images

This commit is contained in:
Thomas E Lackey 2024-02-28 04:36:20 +00:00
parent fb6ad1030f
commit 359607488c

9
run.sh
View File

@ -141,10 +141,11 @@ while true; do
docker system prune --all --force docker system prune --all --force
fi fi
if [[ "${WEBAPP_IMAGE_PRUNE:-true}" == "true" ]]; then if [[ "${WEBAPP_IMAGE_PRUNE:-true}" == "true" ]]; then
OLD_IMAGES="$(docker image ls --quiet --filter 'reference=laconic-webapp')" APP_IMAGES="$(docker image ls --quiet --filter 'reference=laconic-webapp')"
if [[ -n "$OLD_IMAGES" ]]; then DANGLING_IMAGES="$(docker image ls --quiet --filter 'dangling=true')"
echo "Pruning images: $OLD_IMAGES" if [[ -n "$APP_IMAGES" ]] || [[ -n "$DANGLING_IMAGES" ]]; then
docker image rm -f $OLD_IMAGES echo "Pruning images: $APP_IMAGES $DANGLING_IMAGES"
docker image rm -f $APP_IMAGES $DANGLING_IMAGES
fi fi
fi fi
sleep ${CHECK_INTERVAL:-15} sleep ${CHECK_INTERVAL:-15}