Skip to content
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

Merged
merged 1 commit into from Jan 5, 2015

Conversation

brahmaroutu
Copy link
Contributor

Closes #8899
Signed-off-by: Srini Brahmaroutu srbrahma@us.ibm.com

@thaJeztah
Copy link
Member

Does this feature handle a large range of ports well? Thinking of this because I read this issue; #9021

@SvenDowideit
Copy link
Contributor

Docs LGTM - @fredlf @jamtur01

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.
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@brahmaroutu
Copy link
Contributor Author

@thaJeztah publish should not affect the parsing of EXPOSE in the Dockerfile. Do you think of any tests that we should add?

@thaJeztah
Copy link
Member

@brahmaroutu Just wondering if publishing a (silly?) range like 1-65000 would cause problems. (I saw the other issue was worked on and they added some test for a port range 1-5000)

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
Copy link
Contributor

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.

@fredlf
Copy link
Contributor

fredlf commented Nov 14, 2014

LGTM once the little formatting issue is fixed. Many thanks for your help.

@brahmaroutu
Copy link
Contributor Author

@thaJeztah I have added more tests with range of ports.
@fredlf I made changes as per your comments

@thaJeztah
Copy link
Member

Oh, thanks!


deleteAllContainers()

logDone("create - portrange")
Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

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

What about this?

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

@brahmaroutu
Copy link
Contributor Author

Rebased, changed code as per the comments. Thanks for the review.

@jessfraz
Copy link
Contributor

ping @LK4D4

@brahmaroutu brahmaroutu force-pushed the publish_ports_8899 branch 2 times, most recently from 617fce8 to b830793 Compare December 16, 2014 23:32
t.Fatal("Port is not mapped for the port "+port, out)
}
}
if err := deleteContainer(id); err != nil {
Copy link
Contributor

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().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added defer statement.

@md5
Copy link
Contributor

md5 commented Dec 17, 2014

Forgive me if this is something that should be obvious from the diff, but what happens in the --publish-all case? Will Docker map port ranges verbatim for --publish-all or try to assign random ports for every port in the range like it does for single ports in the --publish-all case?

I have a similar question about what happens when someone says -p 20000-29999 without a target port range. Will that map those ports as 20,000 through 29,999 or map them to 10,000 random ports?

@brahmaroutu
Copy link
Contributor Author

@md5 -P option works just as it is today, it will assign random ports at least in my testing 49xxx.

@brahmaroutu brahmaroutu force-pushed the publish_ports_8899 branch 2 times, most recently from 5892d4c to 9d62fc6 Compare December 18, 2014 01:17
@brahmaroutu
Copy link
Contributor Author

@LK4D4 I did a bit of formatting on the docs. Please let me know if I addressed all your concerns.

@brahmaroutu brahmaroutu force-pushed the publish_ports_8899 branch 3 times, most recently from 399d269 to 4113586 Compare December 19, 2014 18:31
@jessfraz
Copy link
Contributor

oh man sorry, this needs another rebase, please ping me after and i will be sure to review and hopefully get it through :)

@brahmaroutu
Copy link
Contributor Author

np, I am happy to rebase. Please see that this gets merged.

Closes moby#8899
Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>
@jessfraz
Copy link
Contributor

jessfraz commented Jan 5, 2015

LGTM

@jessfraz jessfraz removed their assignment Jan 5, 2015
@LK4D4
Copy link
Contributor

LK4D4 commented Jan 5, 2015

LGTM

LK4D4 added a commit that referenced this pull request Jan 5, 2015
add ability to publish range of ports
@LK4D4 LK4D4 merged commit 25f8c26 into moby:master Jan 5, 2015
@md5
Copy link
Contributor

md5 commented Jan 5, 2015

🎆

@thaJeztah
Copy link
Member

\o/

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.

Add support for publishing ranges of ports
7 participants