自从我将计算机上的 Docker 升级到 beta27 后,我就无法使用默认网络运行 Windows 容器了。我收到以下消息:
docker: Error response from daemon: container xxx encountered an error during Start failed in Win32: The system cannot find the path specified. (0x3): Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type.
我已经卸载/删除了所有内容(适用于 Windows 的 Docker、Hyper-V、容器功能以及 C:\ProgramData\Docker 中剩余的文件),然后重新安装了所有内容,但问题仍然存在。
我意识到该nat
适配器不再存在于 Hyper-V 中,但该DockerNat
适配器仍然存在。
本文提供了一个重置网络组件的脚本,但我无法删除容器网络。
PS C:\WINDOWS\system32> Get-ContainerNetwork
Name Id Subnets Mode SourceMac DNSServers DNSSuffix
---- -- ------- ---- --------- ---------- ---------
nat 12706897-fc71-41fc-9046-a7be0d01727e {172.16.0.0/12} NAT
PS C:\WINDOWS\system32> Get-ContainerNetwork | Remove-ContainerNetwork
Confirm
Remove-ContainerNetwork will remove the container network "".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):
Remove-ContainerNetwork : Unspecified error
At line:1 char:24
+ Get-ContainerNetwork | Remove-ContainerNetwork
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Remove-ContainerNetwork], VirtualizationException
+ FullyQualifiedErrorId : OperationFailed,Microsoft.Containers.PowerShell.Cmdlets.RemoveContainerNetwork
PS C:\WINDOWS\system32> Remove-ContainerNetwork -Name nat
Confirm
Remove-ContainerNetwork will remove the container network "nat".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):
Remove-ContainerNetwork : Unspecified error
At line:1 char:1
+ Remove-ContainerNetwork -Name nat
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Remove-ContainerNetwork], VirtualizationException
+ FullyQualifiedErrorId : OperationFailed,Microsoft.Containers.PowerShell.Cmdlets.RemoveContainerNetwork
PS C:\WINDOWS\system32>
由于无法通过 PowerShell 删除网络,我可以删除注册表项来删除网络吗?
答案1
尝试使用以下命令删除 NAT 网络:
Get-NetNat | Remove-NetNat
您也可以尝试重新启动 HNS 和 docker
Restart-Service hns
Restart-Service docker