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

Added API to set ephemeral port allocator range. #2476

Closed
wants to merge 1 commit into from

Conversation

suwang48404
Copy link
Contributor

Also reduce the allowed port range as the total number of containers
per host is typically less than 1K.

This change helps in scenarios where there are other services on
the same host that uses ephemeral ports in iptables manipulation.

The workflow requires changes in docker engine (
moby/moby#40055) and this change. It
works as follows:

  1. user can now specified to docker engine an option
    --published-port-range="50000-60000" as cmdline argument or
    in daemon.json.
  2. docker engine read and pass this info to libnetwork via
    config.go:OptionDynamicPortRange.
  3. libnetwork uses this range to allocate dynamic port henceforth.
  4. --published-port-range can be set either via SIGHUP or
    restart docker engine
  5. if --published-port-range is not set by user, a OS specific
    default range is used for dynamic port allocation.
    Linux: 49153-60999, Windows: 60000-65000
    6 if --published-port-range is invalid, that is, the range
    given is outside of allowed default range, no change takes place.
    libnetwork will continue to use old/existing port range for
    dynamic port allocation.

Signed-off-by: Su Wang su.wang@docker.com

Also reduce the allowed port range as the total number of containers
per host is typically less than 1K.

This change helps in scenarios where there are other services on
the same host that uses ephemeral ports in iptables manipulation.

The workflow requires changes in docker engine (
moby/moby#40055) and this change. It
works as follows:

1. user can now specified to docker engine an option
   --published-port-range="50000-60000" as cmdline argument or
   in daemon.json.
2. docker engine read and pass this info to libnetwork via
   config.go:OptionDynamicPortRange.
3. libnetwork uses this range to allocate dynamic port henceforth.
4. --published-port-range can be set either via SIGHUP or
   restart docker engine
5. if --published-port-range is not set by user, a OS specific
   default range is used for dynamic port allocation.
   Linux: 49153-60999, Windows: 60000-65000
6 if --published-port-range is invalid, that is, the range
  given is outside of allowed default range, no change takes place.
  libnetwork will continue to use old/existing port range for
  dynamic port allocation.

Signed-off-by: Su Wang <su.wang@docker.com>
@suwang48404
Copy link
Contributor Author

@arkodg
Copy link
Contributor

arkodg commented Oct 30, 2019

lets test the functionality end-to-end (add changes to Moby master, add integration tests in Moby) before we cherry-pick into master ?

@suwang48404
Copy link
Contributor Author

lets test the functionality end-to-end (add changes to Moby master, add integration tests in Moby) before we cherry-pick into master ?

Arko, u wanted to add integration test to moby/moby#40055, right?
we can do that.

wanted to make sure that the request is not associated with this PR.

@cpuguy83
Copy link
Member

Note we have migrated this codebase over to github.com/moby/moby/libnetwork.
We are not accepting PR's on this repo anymore except for backports to be included in moby 20.10

@corhere
Copy link
Collaborator

corhere commented Jan 19, 2024

See moby/moby#40055 (comment)

@corhere corhere closed this Jan 19, 2024
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.

None yet

4 participants