Thanks to visit codestin.com
Credit goes to github.com

Skip to content

adding support for port ranges on --expose#8167

Merged
jessfraz merged 1 commit into
moby:masterfrom
brahmaroutu:expose_ports_1834
Oct 31, 2014
Merged

adding support for port ranges on --expose#8167
jessfraz merged 1 commit into
moby:masterfrom
brahmaroutu:expose_ports_1834

Conversation

@brahmaroutu

Copy link
Copy Markdown
Contributor

Addresses #1834

Signed-off-by: Srini Brahmaroutu [email protected]

@brahmaroutu brahmaroutu force-pushed the expose_ports_1834 branch 2 times, most recently from 687a342 to 652bd7b Compare September 22, 2014 17:53
@jessfraz

Copy link
Copy Markdown
Contributor

LGTM, thanks for the patch!

@jessfraz

Copy link
Copy Markdown
Contributor

wouldn't it make sense to add this to -p as well, or what would be the use case for exposing the range without publishing?

@brahmaroutu

Copy link
Copy Markdown
Contributor Author

@jfrazelle I thought about it but I only wanted to add code that originally intended by @jhorey. My thinking is the feature can be used with -P (which I tested) and certainly a new issue should be opened to add support for -p.

@jessfraz

Copy link
Copy Markdown
Contributor

gotcha

@vieux

vieux commented Sep 22, 2014

Copy link
Copy Markdown
Contributor

LGTM

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This string is set from the flag code in runconfig/parse.go (and is updated using a script from the output of docker)

so needs to be set there. Can you also mention in that text the port-port format - I'm not sure we've used a - separator anywhere else, so a non-read the docs reminder would be good.

@brahmaroutu

Copy link
Copy Markdown
Contributor Author

@SvenDowideit I have added the port range to the flag description. I went with a example for port range and hope that works.

Comment thread links/links.go Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe instead of else do

for i := 0; 1 < len(l.Ports); {
    p := l.Ports[i]
    j := nextContiguous(l.Ports, p.Int(), i)
    if j > i+1 {
        env = append(env, fmt.Sprintf("%s_PORT_%s_%s_START=%s://%s:%s", alias, p.Port(), strings.ToUpper(p.Proto()), p.Proto(), l.ChildIP, p.Port()))
        env = append(env, fmt.Sprintf("%s_PORT_%s_%s_ADDR=%s", alias, p.Port(), strings.ToUpper(p.Proto()), l.ChildIP))
        env = append(env, fmt.Sprintf("%s_PORT_%s_%s_PROTO=%s", alias, p.Port(), strings.ToUpper(p.Proto()), p.Proto()))
        env = append(env, fmt.Sprintf("%s_PORT_%s_%s_PORT_START=%s", alias, p.Port(), strings.ToUpper(p.Proto()), p.Port()))

        q := l.Ports[j]
        env = append(env, fmt.Sprintf("%s_PORT_%s_%s_END=%s://%s:%s", alias, p.Port(), strings.ToUpper(q.Proto()), q.Proto(), l.ChildIP, q.Port()))
        env = append(env, fmt.Sprintf("%s_PORT_%s_%s_PORT_END=%s", alias, p.Port(), strings.ToUpper(q.Proto()), q.Port()))

        i = j + 1
        continue
    }

    env = append(env, fmt.Sprintf("%s_PORT_%s_%s=%s://%s:%s", alias, p.Port(), strings.ToUpper(p.Proto()), p.Proto(), l.ChildIP, p.Port()))
    env = append(env, fmt.Sprintf("%s_PORT_%s_%s_ADDR=%s", alias, p.Port(), strings.ToUpper(p.Proto()), l.ChildIP))
    env = append(env, fmt.Sprintf("%s_PORT_%s_%s_PORT=%s", alias, p.Port(), strings.ToUpper(p.Proto()), p.Port()))
    env = append(env, fmt.Sprintf("%s_PORT_%s_%s_PROTO=%s", alias, p.Port(), strings.ToUpper(p.Proto()), p.Proto()))
    i++
}

Just my personal preference.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed code as above, it is lot cleaner.

@brahmaroutu brahmaroutu force-pushed the expose_ports_1834 branch 2 times, most recently from b9b4f9b to 5f03176 Compare September 24, 2014 15:55
@SvenDowideit

Copy link
Copy Markdown
Contributor

The commandline flags documented in cli.md and docker-run.man1.md should be identical to that in the code.

and can you squash your commits when you rebase?

@brahmaroutu

Copy link
Copy Markdown
Contributor Author

@SvenDowideit I squashed my commits and Please see the change to --expose flag, is that what you refer to?

Comment thread runconfig/parse.go

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is the text that should be used in docker-run.1.md, cli.md and run.md - as the text written should look identical to what the user sees when they type docker run ---help.

I have a script that will update it for you (though you need to ignore some of its changes) - docs/docs-update.py ./bundles/1.2.0-dev/binary/docker - this will use your modified docker binary to update the documentation. :)

@brahmaroutu

Copy link
Copy Markdown
Contributor Author

thanks @SvenDowideit, that is a cool tool. I did selectively updated the docs using the tool.

@jessfraz

Copy link
Copy Markdown
Contributor

this needs a rebase and I think we are just waiting on docs approval?

@brahmaroutu

Copy link
Copy Markdown
Contributor Author

Thanks, I just did a rebase

@brahmaroutu

Copy link
Copy Markdown
Contributor Author

Please let me know if there is anything missing? I am still waiting for this merge. @SvenDowideit are the docs look good?

@SvenDowideit

Copy link
Copy Markdown
Contributor

Docs LGTM - @jamtur01 @fredlf @ostezer

@jamtur01

jamtur01 commented Oct 7, 2014

Copy link
Copy Markdown
Contributor

Docs LGTM

@ghost

ghost commented Oct 7, 2014

Copy link
Copy Markdown

Docs LGTM

@SvenDowideit

Copy link
Copy Markdown
Contributor

@jfrazelle @crosbymichael , Docs are happy :)

@brahmaroutu brahmaroutu force-pushed the expose_ports_1834 branch 2 times, most recently from 164cdc8 to 673446f Compare October 14, 2014 18:57
@brahmaroutu

Copy link
Copy Markdown
Contributor Author

Rebased and I hope this can be merged soon.

@brahmaroutu brahmaroutu force-pushed the expose_ports_1834 branch 2 times, most recently from 7e35933 to ab97622 Compare October 20, 2014 18:04
@jessfraz

Copy link
Copy Markdown
Contributor

@brahmaroutu this needs a rebase and then it seems like we should be good to merge sorry for the delay

@jessfraz

Copy link
Copy Markdown
Contributor

also so GH automatically closes the issue can you change the "Addresses" in your first comment to Closes

Closes moby#1834

Signed-off-by: Srini Brahmaroutu <[email protected]>
@brahmaroutu

Copy link
Copy Markdown
Contributor Author

I addressed both the comments.

jessfraz pushed a commit that referenced this pull request Oct 31, 2014
adding support for port ranges on --expose
@jessfraz jessfraz merged commit 92bb497 into moby:master Oct 31, 2014
@md5

md5 commented Oct 31, 2014

Copy link
Copy Markdown
Contributor

It doesn't look like there is corresponding support for publishing a range of ports, just for exposing them. Is there an open issue for that? I couldn't find one.

In most cases, people are doing to want to do a verbatim mapping instead of doing --publish-all, since these port ranges are often used in cases where the server has a well-known port (or multiple) and hands out port assignments as part of a protocol.

@brahmaroutu

Copy link
Copy Markdown
Contributor Author

Yes I am aware of that, it was commented earlier about this issue. I can work on that as this is merged.

@md5

md5 commented Oct 31, 2014

Copy link
Copy Markdown
Contributor

That's great. If there's an open issue, I'd like to subscribe to it. I can create one otherwise.

Thanks!

@brahmaroutu

Copy link
Copy Markdown
Contributor Author

Please open an issue.

@dkirrane

Copy link
Copy Markdown

Is it possible to also do this from the Dockerfile?

EXPOSE 3300-3310

@coolljt0725

Copy link
Copy Markdown
Contributor

@dkirrane yes, you can do EXPOSE 3300-3310 from Dockerfile

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.

9 participants