From 160f4a2c5f46c1cd3bd550a9d8aa9ceea299b2b5 Mon Sep 17 00:00:00 2001 From: mag37 Date: Sat, 29 Nov 2025 17:06:06 +0100 Subject: [PATCH] Test to remove the -tagged copy after backup is created --- dockcheck.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dockcheck.sh b/dockcheck.sh index 01e6ed3..1a3ddd5 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -562,6 +562,7 @@ if [[ -n "${GotUpdates:-}" ]]; then # Add new backup tag prior to pulling if option is set if [[ -n "${DaysKept:-}" ]]; then + ContRepoDigests=$(docker image inspect "$ImageId" --format "{{index .RepoDigests 0}}") ContRepo=${ContImage%:*} ContApp=${ContRepo#*/} [[ "$ContImage" =~ ":" ]] && ContTag=${ContImage#*:} || ContTag="latest" @@ -581,7 +582,13 @@ if [[ -n "${GotUpdates:-}" ]]; then continue fi - docker pull "$ContImage" || { printf "\n%bDocker error, exiting!%b\n" "$c_red" "$c_reset" ; exit 1; } + if docker pull "$ContImage"; then + # Removal of the -tag image left behind from backup + [[ -n "${DaysKept:-}" ]] && docker rmi "$ContRepoDigests" + else + printf "\n%bDocker error, exiting!%b\n" "$c_red" "$c_reset" ; exit 1 + fi + done printf "\n%bDone pulling updates.%b\n" "$c_green" "$c_reset"