luc*_*y15 2 windows containers hyper-v nat docker
我一直在为这件事揪心。在此过程中,似乎一些旧的端口映射已留在我的 Windows Server 2016 docker 服务器中,并且无法删除它们。这是我尝试运行的命令和错误:
PS C:\Users\...\Desktop> Get-NetNatStaticMapping | Remove-NetNatStaticMapping
Confirm
Are you sure you want to perform this action?
Performing operation Delete on Target H54d664a6-523c-4452-b137-d66701623488;20;0 PolicyStore Local
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): a
Remove-NetNatStaticMapping : The requested operation is not supported.
At line:1 char:27
+ Get-NetNatStaticMapping | Remove-NetNatStaticMapping
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (MSFT_NetNatStat...b4d01327e;6...):root/StandardCi...atStaticMapping)
[Remove-NetNatStaticMapping], CimException
+ FullyQualifiedErrorId : Windows System Error 50,Remove-NetNatStaticMapping
Remove-NetNatStaticMapping : The requested operation is not supported.
At line:1 char:27
+ Get-NetNatStaticMapping | Remove-NetNatStaticMapping
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (MSFT_NetNatStat...701623488;2...):root/StandardCi...atStaticMapping)
[Remove-NetNatStaticMapping], CimException
+ FullyQualifiedErrorId : Windows System Error 50,Remove-NetNatStaticMapping
Run Code Online (Sandbox Code Playgroud)
下面的命令显示了两个端口映射...
PS C:\Users\...\Desktop> Get-NetNatStaticMapping
StaticMappingID : 20
NatName : H54d664a6-523c-4452-b137-d66701623488
Protocol : TCP
RemoteExternalIPAddressPrefix : 0.0.0.0/0
ExternalIPAddress : 0.0.0.0
ExternalPort : 443
InternalIPAddress : 172.20.95.205
InternalPort : 443
InternalRoutingDomainId : {00000000-0000-0000-0000-000000000000}
Active : False
StaticMappingID : 6
NatName : H68dfe202-0efd-480b-b78a-53ab4d01327e
Protocol : TCP
RemoteExternalIPAddressPrefix : 0.0.0.0/0
ExternalIPAddress : 0.0.0.0
ExternalPort : 443
InternalIPAddress : 172.31.142.210
InternalPort : 443
InternalRoutingDomainId : {00000000-0000-0000-0000-000000000000}
Active : False
Run Code Online (Sandbox Code Playgroud)
我在 Windows Server 2016 上自动卸载和重新安装 docker,并尝试了所有常用技巧。
以下是我用来在气隙服务器上卸载 docker 的命令:
docker rm -f $(docker ps --all --quiet)
docker system prune --all --volumes -f
Stop-Service docker -Verbose
Stop-Service hns -Verbose
Get-ContainerNetwork | Remove-ContainerNetwork
Get-NetNat | Remove-NetNat -Confirm:$false
Get-VMSwitch -name nat | Remove-VMSwitch -Confirm:$false
Remove-Item -Path "C:\ProgramData\Docker" -Recurse -Force
Remove-WindowsFeature -Name Containers -Verbose
Remove-WindowsFeature -Name Hyper-V -Verbose
Remove-Item C:\ProgramData\Microsoft\Windows\HNS\hns.data -Force
Run Code Online (Sandbox Code Playgroud)
即使如此,我仍然无法删除端口映射,后来当尝试运行另一个将端口 443 转发到容器的 docker 映像时,出现错误:
failed to create endpoint
container_name on network nat: HNS failed with error : The object already exists.
Run Code Online (Sandbox Code Playgroud)
我开始认为我唯一的选择是将服务器恢复到本周早些时候的某个时间点。
任何帮助是极大的赞赏!
为了解决这个问题...删除以下注册表项:
\n\nHKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Nsi\\{eb004a20-9b1a-11d4-9123-0050047759bc}\nRun Code Online (Sandbox Code Playgroud)\n\n删除密钥后,我将从命令中得到空结果:
\n\nGet-NetNat\nGet-NetNatStaticMapping\nRun Code Online (Sandbox Code Playgroud)\n\n作为参考,答案来自此处博客文章的讨论:
\n\nhttps://www.thomasmaurer.ch/2016/05/set-up-a-hyper-v-virtual-switch-using-a-nat-network/
\n\n在这条评论中:
\n\n\n\n我能够解决 \xe2\x80\x9c无效操作\xe2\x80\x9d-错误。实际上,与我共享办公室的 Mircosoft 顾问能够追踪到此问题;-)\n 要删除 NetNat,我无法使用 powershell 命令删除\xc2\xb4t,我必须删除以下注册表 -钥匙:
\n\nHKLM\\System\\CurrentControlSet\\Control\\NSI{eb004a20-\xe2\x80\xa6..7759bc}\\6\\\xe2\x80\xa6.
\n\n两台不同机器上的密钥是相同的,因此这可能始终是相同的 GUID。\n 删除后,NetNat 消失了,我终于能够创建一个新的。然后这就按预期工作了。
\n\n此致,
\n\n塞巴斯蒂安
\n
| 归档时间: |
|
| 查看次数: |
2263 次 |
| 最近记录: |