Skip to content

Add support for host mode port PublishMode in services#27917

Merged
tonistiigi merged 1 commit intomoby:masterfrom
mrjana:ports
Nov 11, 2016
Merged

Add support for host mode port PublishMode in services#27917
tonistiigi merged 1 commit intomoby:masterfrom
mrjana:ports

Conversation

@mrjana
Copy link
Contributor

@mrjana mrjana commented Oct 31, 2016

Add api/cli support for adding host port PublishMode in services.

mrjana@dev-1:~/docker/scripts$ docker service create --name ss2 --publish-host 5000 --publish-ingress 5000 --network foo mrjana/simpleweb simpleweb

mrjana@dev-1:~/docker/scripts$ docker service ps ss2
NAME                             IMAGE             NODE     DESIRED STATE  CURRENT STATE          ERROR  PORTS
ss2.1.xlgwmnomhp609divvy8xdqh5w  mrjana/simpleweb  worker1  Running        Running 9 seconds ago         *:32768->5000/tcp

Signed-off-by: Jana Radhakrishnan [email protected]

@tiborvass tiborvass added the status/failing-ci Indicates that the PR in its current state fails the test suite label Oct 31, 2016
@mrjana mrjana force-pushed the ports branch 2 times, most recently from 937850b to eb65aa2 Compare November 2, 2016 04:35
@icecrime icecrime removed the status/failing-ci Indicates that the PR in its current state fails the test suite label Nov 2, 2016
Copy link
Contributor

@mavenugo mavenugo left a comment

Choose a reason for hiding this comment

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

@mrjana Can you pls document if this will impact existing services (without the PublishMode) and also any compatibility concerns with a mixed cluster of 1.13 manager and 1.12 based workers and vice-versa. Also things to consider for upgrades and downgrades.

Copy link
Contributor

Choose a reason for hiding this comment

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

Given that we have 2 independent publish flags, should we move -p above to hidden ?
flags.MarkHidden("p")

Copy link
Member

@dnephin dnephin Nov 8, 2016

Choose a reason for hiding this comment

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

Edit: I see the proposal now, commented below

Copy link
Contributor

Choose a reason for hiding this comment

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

should we instead change convertPortToPortConfig to take in PublishMode instead of walking the configs again as follows ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to the above comment, shall we hide the existing flag ?

@mavenugo
Copy link
Contributor

mavenugo commented Nov 2, 2016

The design was reviewed under moby/swarmkit#1645 . moving to code-review.

@thaJeztah
Copy link
Member

I put it back to design, I'm a bit confused; we now have three flags (6 if we look at docker service update) to expose a port.

I can see that being very confusing for users, and wonder if we can find a better approach

@mavenugo
Copy link
Contributor

mavenugo commented Nov 3, 2016

@thaJeztah ok. do you have any suggestions ? Lets start from there.

@thaJeztah
Copy link
Member

Current options in --publish on docker run (not service create) to see what
things we may expect

description example
publish a container's port to a random port on the host -p 80
publish a container's port to a specific port on the host -p 1234:80
publish a container's port to a random host port within a specified range -p 8000-9000:80
publish a range of container ports to random ports on the host -p 8000-8010
publish a range of container ports to a range of host ports -p 8000-8010:9000-9010
specify the protocol to publish (udp, tcp) -p 80/udp, -p 1234:80/udp, -p 8000-9000:80/udp, -p 8000-8010/udp, -p 8000-8010:9000-9010/udp
publish the port only on specific IP-addresses -p 127.0.0.1:90:80 -p 192.168.202.120:90:80
publish a container port on a random port on a specific IP-address -p 127.0.0.1::80 (double colon means value omitted)
publish a container port to multiple random ports on a specific IP-address -p 127.0.0.1::80 -p 127.0.0.1::80

@thaJeztah
Copy link
Member

thaJeztah commented Nov 4, 2016

Some feature requests;

@thaJeztah
Copy link
Member

So, my concerns are that (first of all) we tried the -p / --publish flag to be consistent with docker run so that it's easier for people to find themselve "at home" when using docker service create. By "deprecating" / renaming the --publish flag, that's going to be confusing.

Also, more features will be added in future, and we end up with even more flags. I'm not sure if the current -p syntax will make that easy to use. My initial thought was to use a syntax similar to --mount for publishing, as it's extendable, and non ambiguous (albeit verbose), something like

--new-publish-flag target-port=80,published-port=8080,mode=host

In future we can add "porcelain" flags for easier use, if requested.

@mavenugo
Copy link
Contributor

mavenugo commented Nov 6, 2016

@thaJeztah I like this idea which helps with the issue of "grouping" related flags together at the CLI level (which is ofcourse already possible in engine-API & protobuf structures). I wish we make this a consistent pattern and introduce such a "grouping" concept that can be used for more such use-cases.

@yank1
Copy link
Contributor

yank1 commented Nov 7, 2016

LGTM

@mavenugo
Copy link
Contributor

mavenugo commented Nov 8, 2016

@icecrime @cpuguy83 @aluzzardi can you please add your comments / opinion on the UX as proposed by this PR vs @thaJeztah's proposal ?

Given the code-freeze is round the corner, it will be great to have an answer soon so that we can also do integration-testing with WS2016 as well.

@cpuguy83
Copy link
Member

cpuguy83 commented Nov 8, 2016

The --mount style syntax is ok for me.

@icecrime
Copy link
Contributor

icecrime commented Nov 8, 2016

Sebastiaan's proposal makes sense to me. Yes it's verbose, but it's maybe better to get the fundamentals right (as in: non-ambiguous, and future-proof).

@vdemeester
Copy link
Member

Same as @cpuguy83 and @icecrime, I think it makes sense 👼

@mavenugo
Copy link
Contributor

mavenugo commented Nov 8, 2016

thanks @icecrime @cpuguy83 @vdemeester.

@thaJeztah @mrjana shall we reuse --publish flag and overload it with both the formats ?
I think the text parsing is mutually exclusive and we already have sane defaults for the older format.

For example,

-p 80 -> -p target-port=80,mode=ingress
-p 1234:80 -> -p target-port=80,published-port=1234,mode=ingress

etc...

@thaJeztah
Copy link
Member

thaJeztah commented Nov 8, 2016

If we can do it "technically", I am not against reusing the flag

One thing we should look at is how "removing" a published port will work in docker service update (see also #25860). Probably just document that the "target" port needs to be used (and protocol?)

@mrjana
Copy link
Contributor Author

mrjana commented Nov 8, 2016

ping @dnephin. Can you please chime in on the port publication format that is being discussed here? This will override the micro format specification that has been used so far.

Copy link
Member

Choose a reason for hiding this comment

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

These should be publish-ingress-rm, publish-host-rm, same with the add flags

Copy link
Member

@dnephin dnephin Nov 8, 2016

Choose a reason for hiding this comment

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

Edit: I see the proposal now, commented below

@dnephin
Copy link
Member

dnephin commented Nov 8, 2016

Oh, I see the proposal for having the new flags use a different format. I think that makes sense. We need a way to expose more information, and following the mount syntax sounds correct.

I think we should deprecate the old --publush flag at the same time. Deprecating it will hide it, but still allow it to be used for now.

@mrjana
Copy link
Contributor Author

mrjana commented Nov 11, 2016

Rebased

Add api/cli support for adding host port PublishMode in services.

Signed-off-by: Jana Radhakrishnan <[email protected]>
@thaJeztah
Copy link
Member

Linking #28463 (comment) which should be documented as part of the documentation changes for this PR

@rootsongjc
Copy link
Contributor

@mavenugo @thaJeztah I use this command it works.
docker service create --port mode=host,target=80,published=8080,protocol=tcp nginx:1.9
How many mode can I use?
I want to use my own bridge network "mynet", how can I specify it within service?

@thaJeztah
Copy link
Member

thaJeztah commented Nov 30, 2016

@rootsongjc no, currently only "host" or "ingress".

Be aware that after UX reviews, the --port and --publish flags will be combined in 1.13 GA, see the discussion on #28527 (comment) and implemented in #28943

@stevvooe
Copy link
Contributor

stevvooe commented Dec 2, 2016

Here was the original UX proposal:

moby/swarmkit#1645 (comment)

For mount, the syntax complexity made sense due the use of volume options and arbitrary filesystem paths. Ports are much, much simpler and forcing people to navigate this morass for simple port definition isn't great.

I am not sure I understood the main impetus behind using the csv-style syntax.

@Richard-Mathie
Copy link
Contributor

Oh no, this seems to make things more complex.

does this mean there is no straight --publish [port:]port syntax defaulting to the ingress network any more? Is there any documentation on how this affects DNS resolution and any differences between networking for the two modes. I guess this helps to fix external connections to services like kafka, and removes a potential routing hop if you are using nginx.

Is that the rational behind this?

I also dont see the documentation for this in https://github.com/docker/docker/blob/master/docs/reference/commandline/service_create.md
what was the syntax you eventually went with?

@thaJeztah
Copy link
Member

@Richard-Mathie no worries, the "simple" syntax will stay as well; see #28943, and the discussion on #28527

@thaJeztah
Copy link
Member

thaJeztah commented Jan 13, 2017

Documentation is added here; https://github.com/docker/docker.github.io/blob/2248f78dabc2b0e5092fd550ad0aa3c15d41e2b0/engine/swarm/services.md#publish-ports, but we should add it to the command line reference as well

@thaJeztah thaJeztah added the area/networking Networking label Jul 31, 2018
@thaJeztah thaJeztah changed the title Add support for host port PublishMode in services Add support for host mode port PublishMode in services Jul 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.