title: Running Visual Studio Remote Debugger in Windows Container (Docker managed)
body: <p>I try to run the <strong>Visual Studio Remote Debugger</strong> in a <strong>Windows Container</strong> on <strong>Windows Server 2016 TP4</strong>. Since it runs inside a container, there is no UI.</p>
  
  <p>I try to run the remote debugger via:</p>
  
  <pre><code> .\msvsmon.exe /nostatus /silent /nosecuritywarn /nofirewallwarn /noclrwarn /port 4020
  </code></pre>
  
  <p>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.</p>
  
  <pre><code>Msvsmon was unable to start a server named "`6D2D071453C5:4020`". 
  The following error occurred: The parameter is incorrect. 
  </code></pre>
  
  <p>Complete event log:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>I noticed one issue regarding the hostname of the container, but this can be fixed:</p>
  
  <p><code>6D2D071453C5</code> is the <strong>container id</strong> of my Windows container (docker managed):</p>
  
  <pre><code>PS C:&gt; 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
  </code></pre>
  
  <p>Usually, in Docker, this <strong>container id</strong> will also be the <strong>hostname</strong> inside/of the container.</p>
  
  <p>So, when I run <code>docker inspect 6d2d071453c5</code>, I get this in the output:</p>
  
  <pre><code>"Config": {
      "Hostname": "6d2d071453c5",
      "Domainname": "",
  </code></pre>
  
  <p>But then, inside the container, I type "<code>hostname</code>" in the command line and get:</p>
  
  <pre><code>PS C:&gt; hostname
  test2016
  </code></pre>
  
  <p>This is a bug specific to Windows Server 2016 TP4 / Windows Containers at the moment.
  The hostname should not be <code>test2016</code> (the name of the container host, my actual physical Win2016 server) but the container id (<code>6d2d071453c5</code>). 
  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.</p>
  
  <p>Nevertheless, to circumvent the issue, I adjust the host file, adding:</p>
  
  <pre><code>172.16.0.2        6d2d071453c5
  </code></pre>
  
  <p>Now I can ping my own hostname at least.</p>
  
  <pre><code>PS C:\Program Files\Microsoft Visual Studio 14.0\Common7\IDE\Remote Debugger\x64&gt; ping 6D2D071453C5
  
  Pinging 6d2d071453c5 [172.16.0.2] with 32 bytes of data:
  Reply from 172.16.0.2: bytes=32 time&lt;1ms TTL=128
  Reply from 172.16.0.2: bytes=32 time&lt;1ms TTL=128
  </code></pre>
  
  <p>Nevertheless, the remote debugger still does not start, and still says:</p>
  
  <pre><code>Msvsmon was unable to start a server named "`6D2D071453C5:4020`". 
  The following error occurred: The parameter is incorrect.
  </code></pre>
  
  <p>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.</p>
  
  <p>Has anybody gotten the remote debugger to work inside a container?</p>
  
  <p><strong>======= Update ======</strong></p>
  
  <p>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.</p>
  
  <p>Executed inside the container in directory C:\Program Files\Microsoft Visual Studio 14.0\Common7\IDE\Remote Debugger\x64:</p>
  
  <pre><code>&gt; hostname
  WIN-DE6U4068NAF
  
  &gt; ".\msvsmon.exe /nostatus /silent /nosecuritywarn /nofirewallwarn /noclrwarn /port 4020 /hostname WIN-DE6U4068NAF"
  .\msvsmon.exe /nostatus /silent /nosecuritywarn /nofirewallwarn /noclrwarn /port 4020 /hostname WIN-DE6U4068NAF
  
  &gt; netstat -ab | find "4020"
  
  &gt;
  </code></pre>