From 67a7d8ac14bd26e5b9886bd97934c36e21b1116d Mon Sep 17 00:00:00 2001 From: Philip Date: Sun, 8 Mar 2026 21:49:47 +0000 Subject: [PATCH] Automatically re-stop stopped containers after updating --- dockcheck.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dockcheck.sh b/dockcheck.sh index 8c25328..2aeb948 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -650,6 +650,7 @@ if [[ -n "${GotUpdates:-}" ]]; then for i in "${SelectedUpdates[@]}"; do ((CurrentQue+=1)) unset CompleteConfs + ContStopAfter=false # Extract labels and metadata ContConfig=$(docker inspect "$i" --format '{{json .}}') ContLabels=$($jqbin -r '."Config"."Labels"' <<< "$ContConfig") @@ -671,6 +672,7 @@ if [[ -n "${GotUpdates:-}" ]]; then if [[ "$ContStateRunning" == "true" ]]; then printf "\n%bNow recreating (%s/%s): %b%s%b\n" "$c_teal" "$CurrentQue" "$NumberofUpdates" "$c_blue" "$i" "$c_reset" else + ContStopAfter=true printf "\n%bStarting %b%s%b to apply update.%b\n" "$c_yellow" "$c_blue" "$i" "$c_yellow" "$c_reset" fi @@ -697,6 +699,11 @@ if [[ -n "${GotUpdates:-}" ]]; then else ${DockerBin} ${CompleteConfs} ${ContEnvs} up -d ${SpecificContainer} || { printf "\n%bDocker error, exiting!%b\n" "$c_red" "$c_reset" ; exit 1; } fi + + # Restore the stopped state of updated cotainers + if [[ "$ContStopAfter" == true ]]; then + ${DockerBin} ${CompleteConfs} stop ${SpecificContainer} || { printf "\n%bDocker error, exiting!%b\n" "$c_red" "$c_reset" ; exit 1; } + fi done fi printf "\n%bAll updates done!%b\n" "$c_green" "$c_reset"