fix: handle port mappings with explicit IP bindings#60
Merged
Mcrich23 merged 3 commits intoMcrich23:mainfrom Mar 8, 2026
Merged
fix: handle port mappings with explicit IP bindings#60Mcrich23 merged 3 commits intoMcrich23:mainfrom
Mcrich23 merged 3 commits intoMcrich23:mainfrom
Conversation
The previous implementation blindly prepended '0.0.0.0:' to every port specification, causing invalid formats like '0.0.0.0:127.0.0.1:5432:5432' when the compose file already included an IP binding. Introduced composePortToRunArg helper function that: - Handles simple port (e.g., '3000') → '0.0.0.0:3000:3000' - Handles host:container pairs (e.g., '8080:3000') → '0.0.0.0:8080:3000' - Preserves explicit IP bindings (e.g., '127.0.0.1:5432:5432') as-is - Supports IPv6 bracket notation (e.g., '[::1]:3000:3000') - Preserves protocol suffixes (/tcp, /udp) Added comprehensive unit tests covering all port format variations. Fixes the 'invalid publish IPv4 address' error when using explicit IP bindings in docker-compose.yml.
Owner
|
I love this so much. Let me verify on my end and then we can get this merged! |
Mcrich23
requested changes
Mar 6, 2026
Reapply the explicit IP port binding changes without indentation-only churn so the PR stays focused on behavior and easier to review.
Mcrich23
requested changes
Mar 6, 2026
Owner
Mcrich23
left a comment
There was a problem hiding this comment.
Thank you so much for fixing that. One more thing: can you please add a dynamic test for the full check bringing up the container?
Thank you!
Verify compose up/down behavior with an explicit host IP port binding so the runtime path is covered end to end.
Contributor
Author
|
Implemented — I added a dynamic end-to-end test that brings the container up with an explicit IP port mapping and validates the full up/down lifecycle. Details:
Thanks for the review. |
Mcrich23
approved these changes
Mar 8, 2026
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 the "invalid publish IPv4 address" error when docker-compose.yml port mappings include explicit IP bindings (e.g.,
127.0.0.1:5432:5432).Changes
composePortToRunArg()helper function inHelper Functions.swiftthat correctly parses Docker Compose port specifications intocontainer run -pformatconfigService()inComposeUp.swiftto use the new helper instead of blindly prepending0.0.0.0:HelperFunctionsTests.swiftcovering all port format scenariosWhat was wrong
Previous code did:
This produced invalid address
0.0.0.0:127.0.0.1:5432:5432when the port spec already included an IP.How it works now
The new parser intelligently handles all formats:
3000→0.0.0.0:3000:3000(auto-completes)8080:3000→0.0.0.0:8080:3000(adds IP binding)127.0.0.1:5432:5432→127.0.0.1:5432:5432(preserves explicit IP)[::1]:3000:3000→[::1]:3000:3000(preserves IPv6)/tcpor/udpsuffixes preservedTesting
✅ All 70+ existing tests pass
✅ 8 new port conversion tests pass
✅ Build succeeds with no warnings
Closes #59