从 Visual Studio 2017 年起无法连接到 Docker 上的远程调试器

Can't connect to a remote debugger on Docker from Visual Studio 2017

我有一个 Docker Composer 看起来像:

    version: '2.4'

services:

  sql:
    image: sitecore-xm1-sxa-1.9.0-sqldev:9.2.0-windowsservercore-${windows_version}
    volumes:
      - .\build\data\sql:C:\Data
    mem_limit: 2GB
    ports:
      - "44010:1433"

  cd:
    image: sitecore-xm1-sxa-1.9.0-cd:9.2.0-windowsservercore-${windows_version}
    volumes:
      -  .\build\data\cd:C:\inetpub\sc\App_Data\logs
      -  .\build\Website:C:\src
      -  d:\Program Files (x86)\Microsoft Visual Studio17\Professional\Common7\IDE\Remote Debugger:C:\remote_debugger:ro
      -  .\src:c:\unicorn\
      -  .\docker-specific-files:c:\docker-specific-files
    ports:
      - "44002:80"
    expose:
      - "4023"
      - "4022"
      - "4021"
      - "4020"      
    links:
      - sql
    entrypoint: cmd /c "start /B powershell C:/sitecore/scripts/Watch-Directory.ps1 C:/src C:\inetpub\sc & powershell C:/sitecore/scripts/Watch-Directory.ps1 C:/docker-specific-files C:\inetpub\sc -ExcludeFiles @('Web.config','ConnectionStrings.config') & C:\remote_debugger\x64\msvsmon.exe /noauth /anyuser /silent /nostatus /noclrwarn /nosecuritywarn /nofirewallwarn /nowowwarn /timeout:2147483646"

  cm:
    image: registry.valtech.dk/sitecore-xm1-sxa-1.9.0-cm:9.2.0-windowsservercore-${windows_version}
    volumes:
      -  .\build\data\cm:C:\inetpub\sc\App_Data\logs
      -  .\build\Website:C:\src
      -  .\docker-specific-files:c:\docker-specific-files
      -  .\src:c:\unicorn\
      -  d:\Program Files (x86)\Microsoft Visual Studio17\Professional\Common7\IDE\Remote Debugger:C:\remote_debugger:ro
    ports:
      - "44001:80"      
    expose:
      - "4023"
      - "4022"
      - "4021"
      - "4020"
    links:
      - sql
    entrypoint: cmd /c "start /B powershell C:/sitecore/scripts/Watch-Directory.ps1 C:/src C:\inetpub\sc & powershell C:/sitecore/scripts/Watch-Directory.ps1 C:/docker-specific-files C:\inetpub\sc -ExcludeFiles @('Web.config','ConnectionStrings.config') & C:\remote_debugger\x64\msvsmon.exe /noauth /anyuser /silent /nostatus /noclrwarn /nosecuritywarn /nofirewallwarn /nowowwarn /timeout:2147483646" 

Docker 工作正常,我可以连接到它并看到远程调试器 运行 正在工作。

但是 VS 无法像文章中描述的那样找到任何远程调试器 here

我错过了什么,可能是什么问题?

由于您在 Visual Studio 2017 中使用远程调试器,因此您必须公开端口“4022”(您可以在 MS docs: Remote Debugger Port Assignments 找到更多信息)。 根据您在问题中提到的文章,您必须这样映射端口:

cd:
...
  ports:
    - "44002:80"
    - "4022:4022"
...

并且您可以从 Docker Compose 文件中删除 "expose" 部分,因为不需要公开此类端口。