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