【发布时间】:2016-07-25 00:55:27
【问题描述】:
我尝试在 Windows Server 2016 TP4 上的 Windows 容器 中运行 Visual Studio 远程调试器。由于它在容器内运行,因此没有 UI。
我尝试通过以下方式运行远程调试器:
.\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 中,这个 container id 也将是容器内部/的 hostname。
所以,当我运行 docker inspect 6d2d071453c5 时,我会在输出中得到这个:
"Config": {
"Hostname": "6d2d071453c5",
"Domainname": "",
然后,在容器内,我在命令行中输入“hostname”并得到:
PS C:> hostname
test2016
这是目前特定于 Windows Server 2016 TP4 / Windows 容器的错误。
主机名不应该是test2016(容器主机的名称,我的实际物理Win2016服务器),而是容器ID(6d2d071453c5)。
至少,这将是我的预期行为,当我在需要 VM 的 Windows 上运行任何其他容器(即 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"
>
【问题讨论】:
-
添加了有关主机名的 docker 问题:github.com/docker/docker/issues/21762
-
主机名问题似乎是 Server 2016 TP4 中已知的 Windows 容器问题,请参阅 github.com/docker/docker/issues/21762#issuecomment-205904128。但是,我原来的问题仍然存在。
-
主机名问题在 Server 2016 TP5 中得到解决,但是仍然没有远程调试器来处理它。
-
我知道它是一篇旧帖子,但我看到你的 docker ps -a 中没有端口...我认为你的调试器找不到带有端口的 docker 容器,因为你没有在你的中设置 EXPOSE 4020 Dockerfile。
标签: debugging docker containers remote-debugging windows-server-2016