Docker dynamic port range RRS feed

  • Question

  • In windows server 2016, Default dynamic port range is from 49152. But when we create docker container with dynamic port mapping, docker is using ports out of this range also. Below is the detailed output.

    PS C:\Users\Administrator> netsh int ipv4 show dynamicport tcp

    Protocol <g class="gr_ gr_209 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="209" id="209">tcp</g> Dynamic Port Range
    Start <g class="gr_ gr_210 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" data-gr-id="210" id="210">Port      :</g> 49152
    Number of <g class="gr_ gr_211 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" data-gr-id="211" id="211">Ports :</g> 16384

    PS C:\Users\Administrator> docker ps
    CONTAINER ID        IMAGE               COMMAND                   CREATED             STATUS              PORTS                             NAMES
    67f054e21a76        microsoft/iis       "C:\\ServiceMonitor..."   18 minutes ago      Up 18 minutes       80/tcp,>8080/tcp    condescending_engelbart
    a6e94d687b3d        microsoft/iis       "C:\\ServiceMonitor..."   19 minutes ago      Up 19 minutes       80/tcp,>8080/tcp   infallible_feynman
    PS C:\Users\Administrator>

    Can anyone please help me with the port range that windows docker uses and any way to limit this port range.

    Tuesday, June 26, 2018 10:04 AM

All replies

  • Why do you need to limit it instead of just specifying the port you want via compose file?
    Tuesday, June 26, 2018 6:01 PM
  • I have a repro on Server 1709.  I want to use docker '-P' so each container's exposed TCP endpoints have unique port numbers on the host side.  But out of two exposed ports in my container, one is inside, and one is outside, of the expected range.

    C:\Users\barrybo>docker port affectionate_einstein
    22/tcp ->
    80/tcp ->
    C:\Users\barrybo>netsh int ipv4 show dynamicport tcp
    Protocol tcp Dynamic Port Range
    Start Port      : 49152
    Number of Ports : 16384

    Tuesday, July 3, 2018 8:30 PM
  • We are seeing this as well, and sometimes getting a port assigned that is below port 1000 which is crazy.  Any way to control this?
    Thursday, February 14, 2019 10:03 PM
  • Where you ever able to figure this out?

    Tuesday, February 19, 2019 11:19 PM