docker Desktop啟動容器報錯:Ports are not available: listen tcp...,從WSL用docker start能啟動,但映射docker端口之后並不能訪問,是因為windows10 為hyper-V保留了部分端口,解決辦法:
來自 https://github.com/docker/for-win/issues/3171
- Disable hyper-v (which will required a couple of restarts)
dism.exe /Online /Disable-Feature:Microsoft-Hyper-V- 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- 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