fix: PortCommand parser handles single-port query format#232
Merged
joshrotenberg merged 1 commit intomainfrom Jan 6, 2026
Merged
fix: PortCommand parser handles single-port query format#232joshrotenberg merged 1 commit intomainfrom
joshrotenberg merged 1 commit intomainfrom
Conversation
When querying a specific port with `docker port <container> <port>`, Docker returns a simpler format without the container port prefix: 0.0.0.0:8080 [::]:8080 Instead of the full format returned when listing all ports: 80/tcp -> 0.0.0.0:8080 The parser now handles both formats by using the queried port as the container_port when parsing the simple format. Also restores the host_port() test in testing_utilities example now that the underlying bug is fixed. Fixes #231
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
PortCommandparser to handle the simpler output format returned when querying a specific port.Fixes #231
Problem
When querying a specific port with
docker port <container> <port>, Docker returns a simpler format:Instead of the full format returned when listing all ports:
The parser only handled the full format, causing
host_port()inContainerGuardto fail.Solution
Updated
parse_port_mappings()to accept an optionalqueried_portparameter. When the simple format is detected andqueried_portis provided, the container port is inferred from the queried port.Changes
src/command/port.rs: Updated parser to handle both formatsexamples/testing_utilities.rs: Restoredhost_port()test now that the bug is fixedTesting
host_port()verification