Skip to content

Recreate stopped containers without starting#286

Open
chatziko wants to merge 1 commit into
mag37:mainfrom
chatziko:stopped-recreate-only
Open

Recreate stopped containers without starting#286
chatziko wants to merge 1 commit into
mag37:mainfrom
chatziko:stopped-recreate-only

Conversation

@chatziko

Copy link
Copy Markdown

This simple PR makes -s recreate stopped containers using a simple docker compose create, instead of doing start & stop (starting containers and forcefully stopping might have undesirable side effects).

@mag37

mag37 commented May 13, 2026

Copy link
Copy Markdown
Owner

Oh that's very nice! Thank you, I'll need to run some testing and should really merge #271 prior to this - I'll see if I can get them both done asap.

@chatziko

Copy link
Copy Markdown
Author

No hurry. I did some light testing (just updated one stopped container, it worked fine), but we should test more.

@mag37

mag37 commented May 15, 2026

Copy link
Copy Markdown
Owner

Did run it through a few tests now and seems to work as intended, great find @chatziko !
Will merge as is, just gonna see if I can squeeze #271 too.

@mag37

mag37 commented May 15, 2026

Copy link
Copy Markdown
Owner

Okay so I merged #271 to main and things got a bit more complicated to merge :)
And while I was looking at solving that , I considered a situation where both ForceRestartStacks and ContCreateOnly is used.

        if [[ "$ContRestartStack" == true ]] || [[ "$ForceRestartStacks" == true ]]; then
          ${DockerBin} ${CompleteConfs} down; ${DockerBin} ${CompleteConfs} ${ContEnvs} up -d || { printf "\n%bDocker error, exiting!%b\n" "$c_red" "$c_reset" ; exit 1; }
        elif [[ "$ContCreateOnly" == true ]]; then
          ${DockerBin} ${CompleteConfs} ${ContEnvs} create ${SpecificContainer} || { printf "\n%bDocker error, exiting!%b\n" "$c_red" "$c_reset" ; exit 1; }
        else
          ${DockerBin} ${CompleteConfs} ${ContEnvs} up -d ${SpecificContainer} || { printf "\n%bDocker error, exiting!%b\n" "$c_red" "$c_reset" ; exit 1; }
        fi

Then a stopped container would fall into [ "$ForceRestartStacks" == true ]] if that's set, and then gets recreated and started - and left in a running state.
I've not tested this yet, just from trying to re-arrange the code to fit into the new main, so I might be mistaken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants