在Windows容器中运行Visual Studio远程调试器(由Docker管理) [英] Running Visual Studio Remote Debugger in Windows Container (Docker managed)

查看:197
本文介绍了在Windows容器中运行Visual Studio远程调试器(由Docker管理)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在 Windows Server 2016 TP4 上的 Windows容器中运行 Visual Studio远程调试器。由于它运行在容器中,因此没有UI。

I try to run the Visual Studio Remote Debugger in a Windows Container on Windows Server 2016 TP4. Since it runs inside a container, there is no UI.

我尝试通过以下方式运行远程调试器:

I try to run the remote debugger via:

 .\msvsmon.exe /nostatus /silent /nosecuritywarn /nofirewallwarn /noclrwarn /port 4020

我正在以管理员用户(NT Authority\system)的身份执行上述操作。
这在主机上可以正常工作,但是在容器内部不起作用。 Windows事件日志显示以下错误事件。

I am executing the above as administrator user (nt authority\system). This works fine on the host computer, but it does not work inside the container. The Windows event log shows the following error event.

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

我注意到一个问题关于容器的主机名,但这可以固定:

I noticed one issue regarding the hostname of the container, but this can be fixed:

6D2D071453C5 容器ID 我的Windows容器(由docker管理):

6D2D071453C5 is the container id of my Windows container (docker managed):

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 也将是主机名

Usually, in Docker, this container id will also be the hostname inside/of the container.

因此,当我运行 docker inspect 6d2d071453c5 时,我在输出中得到了此信息。 :

So, when I run docker inspect 6d2d071453c5, I get this in the output:

"Config": {
    "Hostname": "6d2d071453c5",
    "Domainname": "",

但是,在容器内部,键入 hostname ,然后获取:

But then, inside the container, I type "hostname" in the command line and get:

PS C:> hostname
test2016

这是Windows Server 2016 TP4 / Windows容器特有的错误时刻。
主机名不应为 test2016 (容器主机的名称,我实际的物理Win2016服务器),而应为容器ID( 6d2d071453c5 )。
至少,这是我的预期行为,当我在需要VM的Windows上运行任何其他容器(即Ubuntu容器)时,也是如此。我只是重新检查了一下。

This is a bug specific to Windows Server 2016 TP4 / Windows Containers at the moment. The hostname should not be test2016 (the name of the container host, my actual physical Win2016 server) but the container id (6d2d071453c5). At least, this would be my expected behaviour and this is also the case when I run any other container, i.e. a Ubuntu container, on Windows that require a VM. I just re-checked it.

不过,为了解决这个问题,我调整了主机文件,并添加了:

Nevertheless, to circumvent the issue, I adjust the host file, adding:

172.16.0.2        6d2d071453c5

现在我可以ping我自己的了至少主机名。

Now I can ping my own hostname at least.

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

不过,远程调试器仍然无法启动,仍然说:

Nevertheless, the remote debugger still does not start, and still says:

Msvsmon was unable to start a server named "`6D2D071453C5:4020`". 
The following error occurred: The parameter is incorrect.

根据随附的帮助文件,我看不到任何参数有什么问题所有参数和选项。

I don't see what's wrong with any of the parameters, according to the accompanied help file that lists all the parameters and options. The very same command works fine on the container host, just not inside the container.

有人让远程调试器在容器内部工作吗?

Has anybody gotten the remote debugger to work inside a container?

=======更新=====

如下所示,我尝试了hostname参数。我再也没有在事件日志中看到任何错误,但是我也没有看到端口4020上正在监听任何东西。

As suggest below, I tried the hostname parameter. I don't see any error in the event log anymore, but I also don't see that anything is listening on port 4020.

在目录C的容器内执行:\程序文件\Microsoft Visual Studio 14.0\Common7\IDE\远程调试器\x64:

Executed inside the container in directory 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"

>


推荐答案

我发现此序列有效:

PS C:\> start-service msvsmon150
PS C:\Program Files\Microsoft Visual Studio 15.0\Common7\IDE\Remote Debugger\x64> .\msvsmon  /noauth /anyuser /silent

start-Service命令将发出关于以下内容的错误信息在Windows 10托管的Windows容器中运行时如何无法启动服务。但是,输入第二条命令后,端口在netstat -ab中显示为已阻止,Visual Studio 2017可以嗅探调试器单元。

The start-Service command will fart out an error about how the service can not start when running in a Windows 10 hosted Windows container. However, after entering the second command, the ports show up as blocked in netstat -ab and Visual Studio 2017 can sniff the debugger unit.

这篇关于在Windows容器中运行Visual Studio远程调试器(由Docker管理)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆