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
fi
if [[ "${WEBAPP_IMAGE_PRUNE:-true}" == "true" ]]; then
OLD_IMAGES="$(docker image ls --quiet --filter 'reference=laconic-webapp')"
if [[ -n "$OLD_IMAGES" ]]; then
echo "Pruning images: $OLD_IMAGES"
docker image rm -f $OLD_IMAGES
APP_IMAGES="$(docker image ls --quiet --filter 'reference=laconic-webapp')"
DANGLING_IMAGES="$(docker image ls --quiet --filter 'dangling=true')"
if [[ -n "$APP_IMAGES" ]] || [[ -n "$DANGLING_IMAGES" ]]; then
echo "Pruning images: $APP_IMAGES $DANGLING_IMAGES"
docker image rm -f $APP_IMAGES $DANGLING_IMAGES
fi
fi
sleep ${CHECK_INTERVAL:-15}