Commit Graph

6 Commits

Author SHA1 Message Date
Sebastiaan van Stijn b4b2a0323b
libnetwork/portallocator: un-export consts for defaults
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-06-02 22:59:32 +02:00
Albin Kerouanton 414dd017b3
Revert "Added API to set ephemeral port allocator range."
Since commit 2c4a868f64, Docker doesn't
use the value of net.ipv4.ip_local_port_range when choosing an ephemeral
port. This change reverts back to the previous behavior.

Fixes #43054.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2022-06-02 22:56:18 +02:00
Sebastiaan van Stijn 1f90fdd973
portallocator: use const for default port-ranges, instead of init()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-06-10 10:52:49 +02:00
Su Wang 2c4a868f64 Added API to set ephemeral port allocator range.
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 (
https://github.com/moby/moby/pull/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>
2019-10-11 18:48:07 +00:00
Pradip Dhara 1909ecb27a Pick a random host port if the user does not specify a host port.
For overlay, l2bridge, and l2tunnel, if the user does not specify a host port, windows driver will select a random port for them.  This matches linux behavior.
For ics and nat networks the windows OS will choose the port.

Signed-off-by: Pradip Dhara <pradipd@microsoft.com>
2019-04-22 17:43:27 +00:00
John Howard 55b80035ed Don't build portallocator on Windows
Signed-off-by: John Howard <jhoward@microsoft.com>
2018-09-13 09:20:03 -07:00