docker / for-win

Bug reports for Docker Desktop for Windows
https://www.docker.com/products/docker#/windows
1.86k stars 290 forks source link

Container port binding working randomly #7196

Closed hawm closed 4 years ago

hawm commented 4 years ago

Expected behavior

Container listen all my defined ports after start.

Actual behavior

Container ports are listening randomly, like below

  1. all listening
  2. part listening
  3. all not listening

Restart the container will randomly change to one of the states describe above.

Information

Steps to reproduce the behavior

Dockerfile: https://github.com/discourse/discourse_docker/blob/master/image/discourse_dev/Dockerfile How i boot container: https://github.com/discourse/discourse/blob/master/bin/docker/boot_dev

  1. git clone https://github.com/discourse/discourse.git
  2. run bin/boot_dev to boot container inside repo which be cloned above.
  3. run sudo netstat -tulpn | grep LISTEN or whatever command to check port using you want, you may see one of the states i describe at Actual behavior section above, some ports are not listening at sometime.
  4. restart the container
  5. repeat step 3 to 5
onomatopellan commented 4 years ago

There is a known bug in WSL2 when coming from a shutdown state. Can you restart Windows and see if still happens?

hawm commented 4 years ago

There is a known bug in WSL2 when coming from a shutdown state. Can you restart Windows and see if still happens?

It's keep happening whatever i restart the Windows or WSL many times. I possible see some similar issues about this but not sure , could you point me out where the known bugs related issue it is?

onomatopellan commented 4 years ago

If a restart didn't fix it then is a different issue. Localhost port forwarding fails when Fast Startup is enabled https://github.com/microsoft/WSL/issues/5298

onomatopellan commented 4 years ago

If it helps, I can't reproduce the issue in latest insider build 19645. Restarted the container twice.

Annotation 2020-06-12 135239

hawm commented 4 years ago

But i can reproduce it. And i had disable fast boot by follow https://github.com/microsoft/WSL/issues/5298#issuecomment-636665289 image image image

And i finally found that the higher ports (>10000) are working well??

onomatopellan commented 4 years ago

Ah, that sounds like https://github.com/microsoft/WSL/issues/5306 What's the output of netsh int ipv4 show excludedportrange protocol=tcp ?

hawm commented 4 years ago

Ah, that sounds like microsoft/WSL#5306 What's the output of netsh int ipv4 show excludedportrange protocol=tcp ?

But the ports what i am using for container are not listing by the command output image

onomatopellan commented 4 years ago

what's the output of netsh int ipv4 show dynamicport tcp ?

hawm commented 4 years ago
Protocol tcp Dynamic Port Range                                                                                        
 ---------------------------------                                                                                       
Start Port      : 1024                                                                                                  
Number of Ports : 13977    
onomatopellan commented 4 years ago

See https://github.com/docker/for-win/issues/3171#issuecomment-554587817

Mine:

Protocol tcp Dynamic Port Range                                                                                        
 ---------------------------------                                                                                       
Start Port      : 49152                                                                                                  
Number of Ports : 16384
hawm commented 4 years ago

Thanks a lot, it's working now.

onomatopellan commented 4 years ago

You're welcome. Just out of curiosity, when was the last time you did a Windows clean install?

hawm commented 4 years ago

Almost 2 years ago

docker-robott commented 4 years ago

Closed issues are locked after 30 days of inactivity. This helps our team focus on active issues.

If you have found a problem that seems similar to this, please open a new issue.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. /lifecycle locked