Fix rollout failing when existing containers are in exited state#62
Open
Fikralaksana wants to merge 3 commits into
Open
Fix rollout failing when existing containers are in exited state#62Fikralaksana wants to merge 3 commits into
Fikralaksana wants to merge 3 commits into
Conversation
wowu
requested changes
Mar 11, 2026
wowu
left a comment
Owner
There was a problem hiding this comment.
Thanks for the contribution!
All changes to docker rollout must work in POSIX sh, work with docker compose v1 and v2, and don't expect any special tools like jq to be installed on the machine.
Use `docker compose ps --quiet` (running) vs `ps -a --quiet` (all) to detect exited containers without parsing JSON. Drops the jq dependency to keep the script portable to plain POSIX sh, per maintainer feedback. Also removes the `==` bashism and the `exit 0` inside the piped `while read` (which only exited the subshell, never the script). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Diff `ps -a --quiet` against `ps --quiet` to identify the specific stopped container IDs, then `docker rm` only those and refill with `compose up --detach --no-recreate`. The running replicas are left untouched, preserving the zero-downtime contract when config has drifted (the common case when rollout is invoked). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #20
When a service has containers in an exited state, docker rollout would attempt to restart the old (failed) container due to the --no-recreate flag, instead of creating a new container with the updated compose configuration.
This PR adds container state detection before starting services:
Problem