Docker 之 Windows Hyper-V 导致的端口占用问题
为什么会出现保留端口?
为什么排除一个系统的保留端口执行的是 "netsh interface ipv4 add excludeportrange ..." 而不是 "netsh interface ipv4 delete excludeportrange ..."?
"netsh interface ipv4 show excludedportrange protocol=tcp" 中的 "Administered port exclusions" 是啥意思?
以上问题可以参考:https://stackoverflow.com/questions/58216537/what-is-administered-port-exclusions-in-windows-10
netstat 查不到,启动程序却提示端口占用的解决办法:
# 显示动态端口范围
netsh int ipv4 show dynamicport tcp
# 显示例外端口范围
netsh interface ipv4 show excludedportrange protocol=tcp
# 如果提示被占用的端口在例外端口范围中,执行以下步骤
# 禁用Hyper-V
dism.exe /Online /Disable-Feature:Microsoft-Hyper-V
# 添加例外端口 把这条命令的 1099 换成被占用的端口即可
netsh int ipv4 add excludedportrange protocol=tcp startport=1099 numberofports=1
# 启动Hyper-V
dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All
以下是常用命令:
# 禁用Hyper-V
dism.exe /Online /Disable-Feature:Microsoft-Hyper-V
# 启动Hyper-V
dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All
# 显示动态端口范围
netsh int ipv4 show dynamicport tcp
# 显示例外端口范围
netsh interface ipv4 show excludedportrange protocol=tcp
# 设置动态端口TCP范围
netsh int ipv4 set dynamicport tcp start=1024 num=13977
# 设置动态端口UDP范围
netsh int ipv4 set dynamicport udp start=1024 num=13977
# 添加例外端口
netsh int ipv4 add excludedportrange protocol=tcp startport=1099 numberofports=1