我尝试在 Windows Server 2016 TP4 上的 Windows Container 中运行 Visual Studio远程调试器。由于它在容器内部运行,因此没有用户界面。
我尝试通过以下方式运行远程调试器:
.\msvsmon.exe /nostatus /silent /nosecuritywarn /nofirewallwarn /noclrwarn /port 4020
我正在以管理员用户(nt authority\system)执行上述操作。 这在主机计算机上运行良好,但在容器内部无法运行。Windows事件日志显示以下错误事件。
Msvsmon was unable to start a server named "`6D2D071453C5:4020`".
The following error occurred: The parameter is incorrect.
完整的事件日志:
Get-EventLog -LogName Application -EntryType Error | format-list
Index : 1718
EntryType : Error
InstanceId : 3221226473
Message : The description for Event ID '-1073740823' in Source 'Visual Studio Remote Debugger' cannot be found. The local computer may not have the necessary registry information or message DLL
files to display the message, or you may not have permission to access them. The following information is part of the event:'Msvsmon was unable to start a server named
'6D2D071453C5:4020'. The following error occurred: The parameter is incorrect.
View Msvsmon's help for more information.'
Category : (0)
CategoryNumber : 0
ReplacementStrings : {Msvsmon was unable to start a server named '6D2D071453C5:4020'. The following error occurred: The parameter is incorrect.
View Msvsmon's help for more information.}
Source : Visual Studio Remote Debugger
TimeGenerated : 05.04.2016 9:47:19 AM
TimeWritten : 05.04.2016 9:47:19 AM
UserName : NT AUTHORITY\SYSTEM
我注意到容器的主机名存在一个问题,但这可以修复:
6D2D071453C5
是我的Windows容器(由docker管理)的容器ID
PS C:> docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6d2d071453c5 d9d15fbca6d7 "cmd /S /C 'C:\\myprg-" 6 days ago Up 3 days derrin
通常,在Docker中,这个容器ID也将是容器内/内部的主机名。
所以,当我运行docker inspect 6d2d071453c5
时,在输出中会得到以下内容:
"Config": {
"Hostname": "6d2d071453c5",
"Domainname": "",
但是,在容器内部,我在命令行中键入"hostname
",并获得以下输出:
PS C:> hostname
test2016
这是目前仅限于Windows Server 2016 TP4 / Windows Containers的一个特定错误。
主机名不应该是test2016
(容器主机名称,我的实际物理Win2016服务器的名称),而应该是容器ID(6d2d071453c5
)。
至少,这将是我期望的行为,并且当我在Windows上运行需要VM的任何其他容器,例如Ubuntu容器时,情况也是如此。我刚刚重新检查了一下。
尽管如此,为了绕过此问题,我调整了主机文件,添加了:
172.16.0.2 6d2d071453c5
现在我至少可以ping通自己的主机名。
PS C:\Program Files\Microsoft Visual Studio 14.0\Common7\IDE\Remote Debugger\x64> ping 6D2D071453C5
Pinging 6d2d071453c5 [172.16.0.2] with 32 bytes of data:
Reply from 172.16.0.2: bytes=32 time<1ms TTL=128
Reply from 172.16.0.2: bytes=32 time<1ms TTL=128
然而,远程调试器仍未启动,并且仍然显示:
Msvsmon was unable to start a server named "`6D2D071453C5:4020`".
The following error occurred: The parameter is incorrect.
根据附带的帮助文件列出的所有参数和选项,我看不出任何参数有什么问题。相同的命令在容器主机上可以正常工作,但在容器内部却不能。
有人成功地让远程调试器在容器内部运行吗?
======= 更新 ======
如下建议,我尝试了主机名参数。现在事件日志中不再出现任何错误,但是我也没有看到任何东西在4020端口上监听。
在 C:\Program Files\Microsoft Visual Studio 14.0\Common7\IDE\Remote Debugger\x64 目录下在容器内执行:
> hostname
WIN-DE6U4068NAF
> ".\msvsmon.exe /nostatus /silent /nosecuritywarn /nofirewallwarn /noclrwarn /port 4020 /hostname WIN-DE6U4068NAF"
.\msvsmon.exe /nostatus /silent /nosecuritywarn /nofirewallwarn /noclrwarn /port 4020 /hostname WIN-DE6U4068NAF
> netstat -ab | find "4020"
>