Repository navigation
Wait for in-progress container removal before starting Compose services - #1359
Draft
Christof Marti (chrmarti) wants to merge 2 commits into
Draft
Christof Marti (chrmarti) wants to merge 2 commits into
Christof Marti (chrmarti) wants to merge 2 commits into
Conversation
A Rebuild can leave the previous Compose container in the 'removing' state while 'up' runs. Starting it with 'up --no-recreate' then fails with 'container is marked for removal and cannot be started'. Wait for the removal to finish and create a new container instead. removeContainer also gave up after 7 attempts (about 7 seconds) while a removal was in progress. Wait up to 5 minutes instead, since removing large containers can take longer. Fixes microsoft/vscode-remote-release#11967 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A container in the removing state can be automatically replaced despite --expect-existing-container, silently creating a new environment when the caller requires an existing one.
1 open issue
What changed in this PR
Updates Compose dev-container startup to wait for an old container’s removal before creating its replacement, addressing rebuild failures caused by containers still marked removing.
Changes:
- Detects removing Compose containers and waits before replacement.
- Extends retries for in-progress removal from seven attempts to a five-minute window.
- Adds a regression test covering eight removal conflicts followed by success.
| File | Description |
|---|---|
src/test/dockerUtils.test.ts |
Tests removal retries beyond the previous seven-attempt limit. |
src/spec-shutdown/dockerUtils.ts |
Adds a five-minute retry window and a one-time waiting message. |
src/spec-node/dockerCompose.ts |
Routes containers marked removing through removal before startup. |
Review effort: Balanced
With --expect-existing-container, a Compose container in the removing state passed the existence check and was then replaced by a new one. Reject it like the single-container path does. Also test that waiting for an in-progress removal stops after five minutes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This branch has not been deployed
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.

A Rebuild can leave the previous Docker Compose container in the
removingstate whiledevcontainer upruns (for example, when the old window's shutdown monitor is still removing it).findComposeContainerreturns that container andup -d --no-recreatethen fails with "container is marked for removal and cannot be started". Single-container configs already skipremovingcontainers infindDevContainer, but Compose has to wait because the old container keeps the<project>-<service>-1name until it is gone.Changes:
removingstate, wait for its removal to finish ("Waiting for existing container to be removed.") and create a new container.removeContainer: while Docker reports "removal of container ... is already in progress", keep waiting for up to 5 minutes instead of giving up after 7 attempts (about 7 s). Removing large containers can take longer (19 s in the report).Validation:
exec: 8 "already in progress" conflicts, then success. It fails without the change.docker rm -fon a Compose dev container with 2M files, thendevcontainer up. Without the change,upfails atdocker compose up(removal took about 46 s). With the change, it waits about 38 s and creates a new container.Fixes microsoft/vscode-remote-release#11967