From 359607488cab732b87ee30f73fc2c75ec1929946 Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Wed, 28 Feb 2024 04:36:20 +0000 Subject: [PATCH] Prune dangling images --- run.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/run.sh b/run.sh index 509658b..bf06a4c 100755 --- a/run.sh +++ b/run.sh @@ -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}