-
Notifications
You must be signed in to change notification settings - Fork 3
Fixed teardown logic #194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed teardown logic #194
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -58,9 +58,9 @@ jobs: | |||||||||||||||||||||
| echo "$GHCR_TOKEN" | docker login ghcr.io -u "$GHCR_USER" --password-stdin | ||||||||||||||||||||||
| docker pull "$IMAGE" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Tear down the currently running container (if any). | ||||||||||||||||||||||
| docker stop ghcr.io/dev-chat/muzzle:latest 2>/dev/null || true | ||||||||||||||||||||||
| docker rm ghcr.io/dev-chat/muzzle:latest 2>/dev/null || true | ||||||||||||||||||||||
| # Tear down any running containers from this image. | ||||||||||||||||||||||
| docker stop $(docker ps -q --filter ancestor="$IMAGE") 2>/dev/null || true | ||||||||||||||||||||||
| docker rm $(docker ps -aq --filter ancestor="$IMAGE") 2>/dev/null || true | ||||||||||||||||||||||
|
Comment on lines
+62
to
+63
|
||||||||||||||||||||||
| docker stop $(docker ps -q --filter ancestor="$IMAGE") 2>/dev/null || true | |
| docker rm $(docker ps -aq --filter ancestor="$IMAGE") 2>/dev/null || true | |
| CONTAINERS="$(docker ps -q --filter ancestor="$IMAGE")" | |
| if [ -n "$CONTAINERS" ]; then | |
| docker stop $CONTAINERS 2>/dev/null || true | |
| fi | |
| CONTAINERS_ALL="$(docker ps -aq --filter ancestor="$IMAGE")" | |
| if [ -n "$CONTAINERS_ALL" ]; then | |
| docker rm $CONTAINERS_ALL 2>/dev/null || true | |
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docker pull "$IMAGE"updates the local:latesttag before you query containers by--filter ancestor="$IMAGE". Sinceancestoris resolved to an image ID, this can fail to match (and therefore not stop/remove) containers that were started from the previous:latestimage. Consider capturing the container IDs to stop/remove before pulling, or stop/remove by a stable container name/label instead of theancestorfilter.