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
add ability to publish range of ports #9097
Conversation
767f67e
to
40364a9
Compare
Does this feature handle a large range of ports well? Thinking of this because I read this issue; #9021 |
format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort | containerPort | ||
`hostPort` can be a range of ports (e.g. 49160-49170) and `containerPort` can be | ||
a range of ports (e.g. 3300-3310). When specifying ranges for both the number of | ||
container ports in the range must match number host ports in the range. |
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.
Needs some cleanup, simplification, and clarification. Suggest:
Both hostPort
and containerPort
can be specified as a range of ports. When specifying ranges for both, the number of container ports in the range must match the number of host ports in the range. E.g., a complete example
.
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.
@fredlf Please check the changes I made to the docs as suggested.
40364a9
to
15c3054
Compare
@thaJeztah publish should not affect the parsing of EXPOSE in the Dockerfile. Do you think of any tests that we should add? |
@brahmaroutu Just wondering if publishing a (silly?) range like I haven't properly looked into the other issue to see what the bottleneck was there, but when working with ranges, that testing some "extremes" may be a good thing. Obviously the problem might be what to test; if it works, or also if the performance of it doesn't regress. These are just suggestions btw, I hope the maintainers can provide info if this is actually doable and useful, |
@@ -523,9 +523,12 @@ Creates a new container. | |||
'container:<name|id>': reuses another container network stack | |||
'host': use the host network stack inside the container. Note: the host mode gives the container full access to local system services such as D-bus and is therefore considered insecure. | |||
-P, --publish-all=false Publish all exposed ports to the host interfaces | |||
-p, --publish=[] Publish a container's port to the host | |||
-p, --publish=[] Publish a container's port, or a range of ports (e.g. -p 3300-3310), to the host |
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.
Need a comma after e.g., and code needs to be in backticks (`). Also below. Thanks.
LGTM once the little formatting issue is fixed. Many thanks for your help. |
15c3054
to
e4e4f16
Compare
@thaJeztah I have added more tests with range of ports. |
Oh, thanks! |
d656fca
to
c8da86f
Compare
|
||
deleteAllContainers() | ||
|
||
logDone("create - portrange") |
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.
can we do port range
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.
What about this?
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.
I do not understand, I am doing check on port range, is it what you meant?
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.
No, it is just about rewording done message. port range publishing
instead of portrange
.
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.
Yikes, I took @jfrazelle 's comment differently, as we had earlier port checking issues with other bug fixes, I really went ahead and implemented checking on entire port range(for loop). I got this fixed now. Sorry about that.
c8da86f
to
0518031
Compare
Rebased, changed code as per the comments. Thanks for the review. |
ping @LK4D4 |
617fce8
to
b830793
Compare
t.Fatal("Port is not mapped for the port "+port, out) | ||
} | ||
} | ||
if err := deleteContainer(id); err != nil { |
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.
I don't see why you need to check this in this test, we usually use defer deleteAllContainers()
.
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.
added defer statement.
Forgive me if this is something that should be obvious from the diff, but what happens in the I have a similar question about what happens when someone says |
@md5 -P option works just as it is today, it will assign random ports at least in my testing 49xxx. |
5892d4c
to
9d62fc6
Compare
@LK4D4 I did a bit of formatting on the docs. Please let me know if I addressed all your concerns. |
399d269
to
4113586
Compare
oh man sorry, this needs another rebase, please ping me after and i will be sure to review and hopefully get it through :) |
4113586
to
18e7312
Compare
np, I am happy to rebase. Please see that this gets merged. |
18e7312
to
c2f6bd2
Compare
Closes moby#8899 Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>
c2f6bd2
to
2338a9c
Compare
LGTM |
LGTM |
add ability to publish range of ports
🎆 |
\o/ |
Closes #8899
Signed-off-by: Srini Brahmaroutu srbrahma@us.ibm.com