Skip to content

Handle compose down with container_name case - #39

Closed
rtoohil wants to merge 1 commit into
Mcrich23:mainfrom
rtoohil:feature/compose-down-not-stopping-containers
Closed

rtoohil wants to merge 1 commit into
Mcrich23:mainfrom
rtoohil:feature/compose-down-not-stopping-containers

Conversation

@rtoohil

@rtoohil rtoohil commented Dec 1, 2025

Copy link
Copy Markdown
Contributor

If you use container_name: with a custom name in your compose file, compose up properly handles that, but compose down does not, and defaults to its internal naming, will fail to stop the container, and will not throw an error, because it eats the error.

See #38

This should resolve that case. PR contributed to with Claude.

@Mcrich23 Mcrich23 self-assigned this Dec 3, 2025

@Mcrich23 Mcrich23 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! Thank you

Would it be possible to add a new dynamic test for this? You can just make a new file in Tests/Container-Compose-DynamicTests called ComposeDownTests.swift. It could probably just bring up a container and then shut it down and make sure that everything goes up and down.

oxisto added a commit to oxisto/Container-Compose that referenced this pull request Jan 30, 2026
This provies the missing tests for PR Mcrich23#39
oxisto added a commit to oxisto/Container-Compose that referenced this pull request Jan 30, 2026
This provies the missing tests for PR Mcrich23#39
@oxisto

oxisto commented Jan 30, 2026

Copy link
Copy Markdown
Contributor

This looks great! Thank you

Would it be possible to add a new dynamic test for this? You can just make a new file in Tests/Container-Compose-DynamicTests called ComposeDownTests.swift. It could probably just bring up a container and then shut it down and make sure that everything goes up and down.

I took the liberty of adding said test in #50, also with a little bit of a test hardness to quickly copy the YAML stuff in the correct folder.

@rtoohil

rtoohil commented Jan 31, 2026

Copy link
Copy Markdown
Contributor Author

Thanks! I've been hit with the real life bug and haven't had time to get back to these PRs, but I appreciate the help of adding the test!

Mcrich23 added a commit that referenced this pull request Feb 4, 2026
* Handle compose down with container_name case

* Providing tests for `container-compose down`

This provies the missing tests for PR #39

* Correctly asserting up/down

* Added copyYamlToTemporaryLocation as test helper

* Addressing code review

* test expect cleanup for containers running and stopping

* Update ComposeDownTests.swift

* Update ComposeDownTests.swift

* Update ComposeDownTests.swift

---------

Co-authored-by: rtoohil <[email protected]>
Co-authored-by: Morris Richman <[email protected]>
@Mcrich23 Mcrich23 closed this Feb 6, 2026
@Mcrich23

Mcrich23 commented Feb 6, 2026

Copy link
Copy Markdown
Owner

Merged this with #50.

explicitcontextualunderstanding pushed a commit to explicitcontextualunderstanding/Container-Compose that referenced this pull request Feb 27, 2026
* Handle compose down with container_name case

* Providing tests for `container-compose down`

This provies the missing tests for PR Mcrich23#39

* Correctly asserting up/down

* Added copyYamlToTemporaryLocation as test helper

* Addressing code review

* test expect cleanup for containers running and stopping

* Update ComposeDownTests.swift

* Update ComposeDownTests.swift

* Update ComposeDownTests.swift

---------

Co-authored-by: rtoohil <[email protected]>
Co-authored-by: Morris Richman <[email protected]>
explicitcontextualunderstanding pushed a commit to explicitcontextualunderstanding/Container-Compose that referenced this pull request Mar 31, 2026
* Handle compose down with container_name case

* Providing tests for `container-compose down`

This provies the missing tests for PR Mcrich23#39

* Correctly asserting up/down

* Added copyYamlToTemporaryLocation as test helper

* Addressing code review

* test expect cleanup for containers running and stopping

* Update ComposeDownTests.swift

* Update ComposeDownTests.swift

* Update ComposeDownTests.swift

---------

Co-authored-by: rtoohil <[email protected]>
Co-authored-by: Morris Richman <[email protected]>
YvanY0 added a commit to YvanY0/Container-Compose that referenced this pull request Jun 21, 2026
ComposeUp had three places (getIPForRunningService, waitUntilServiceIsRunning,
stopOldStuff) that hard-coded the container name as
"\(projectName)-\(serviceName)" instead of reading service.container_name.
When a compose file set an explicit container_name, the container started
correctly (container run --name used the right value), but the post-start
lookups waited for the wrong name and timed out after 30s.

Extract a single Service.containerName(projectName:serviceName:) helper and
replace all five call sites (four in ComposeUp, one in ComposeDown) with it.
ComposeDown already had the equivalent inline logic from PR Mcrich23#39; this commit
replaces that with the same helper for consistency.

Fixes Mcrich23#38 (upstream issue; the down side was fixed in PR Mcrich23#39, the up side was
not addressed until now).
YvanY0 added a commit to YvanY0/Container-Compose that referenced this pull request Jun 21, 2026
ComposeUp had three places (getIPForRunningService, waitUntilServiceIsRunning,
stopOldStuff) that hard-coded the container name as
"\(projectName)-\(serviceName)" instead of reading service.container_name.
When a compose file set an explicit container_name, the container started
correctly (container run --name used the right value), but the post-start
lookups waited for the wrong name and timed out after 30s.

Extract a single Service.containerName(projectName:serviceName:) helper and
replace all five call sites (four in ComposeUp, one in ComposeDown) with it.
ComposeDown already had the equivalent inline logic from PR Mcrich23#39; this commit
replaces that with the same helper for consistency.

Fixes Mcrich23#38
YvanY0 added a commit to YvanY0/Container-Compose that referenced this pull request Jun 21, 2026
ComposeUp had three places (getIPForRunningService, waitUntilServiceIsRunning,
stopOldStuff) that hard-coded the container name as
"\(projectName)-\(serviceName)" instead of reading service.container_name.
When a compose file set an explicit container_name, the container started
correctly (container run --name used the right value), but the post-start
lookups waited for the wrong name and timed out after 30s.

Extract a single Service.containerName(projectName:serviceName:) helper and
replace all five call sites (four in ComposeUp, one in ComposeDown) with it.
ComposeDown already had the equivalent inline logic from PR Mcrich23#39; this commit
replaces that with the same helper for consistency.
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.

4 participants