docker 踩坑記錄:WSL DOCKER DESKTOP Ports are not available: listen tcp...


docker Desktop啟動容器報錯:Ports are not available: listen tcp...,從WSL用docker start能啟動,但映射docker端口之后並不能訪問,是因為windows10 為hyper-V保留了部分端口,解決辦法:
來自 https://github.com/docker/for-win/issues/3171

  1. Disable hyper-v (which will required a couple of restarts)
    dism.exe /Online /Disable-Feature:Microsoft-Hyper-V
  2. When you finish all the required restarts, reserve the port you want so hyper-v doesn't reserve it back
    netsh int ipv4 add excludedportrange protocol=tcp startport=50051 numberofports=1
  3. Re-Enable hyper-V (which will require a couple of restart)
    dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All

其他相關命令(參考微軟文檔:The default dynamic port range for TCP/IP has changed)
查看保留的端口:
netsh interface ipv4 show excludedportrange protocol=tcp
查看當前占用端口的進程:
netstat –ano|findstr “port”
查看當前動態端口范圍:
netsh int ipv[46] show dynamicport tcp
設置動態端口范圍:
netsh int ipv[46] set dynamic tcp start=49152 num=16384


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM