From 32f3dfbb2c21bb5d5125b50816d50a360d75940c Mon Sep 17 00:00:00 2001 From: Philip Baylas Date: Wed, 11 Mar 2026 15:50:38 +0000 Subject: [PATCH] When -s flag is used, start stopped containers so they are updated and then stop them again (#269) * Start stopped containers (when -s is used) so that updates apply * Automatically re-stop stopped containers after updating --- dockcheck.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dockcheck.sh b/dockcheck.sh index fc8392b..00e5b5f 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,8 +672,8 @@ 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 - printf "\n%bSkipping recreation of %b%s%b as it's not running.%b\n" "$c_yellow" "$c_blue" "$i" "$c_yellow" "$c_reset" - continue + ContStopAfter=true + printf "\n%bRecreating %b%s%b to apply update - then stopping to return to current state.%b\n" "$c_yellow" "$c_blue" "$i" "$c_yellow" "$c_reset" fi # Checking if compose-values are empty - hence started with docker run @@ -698,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"