通过Visual Studio远程调试docker容器

时间:2018-05-31 20:27:05

标签: visual-studio docker dockerfile

我能够成功启用对我在本地计算机上运行的Docker容器的VSO调试器支持,如下所示:

第1步: 将以下内容添加到我的Dockerfile:

 {
    "builders": [
      {
        "type": "virtualbox-iso",
        "vm_name": "{{ user `alias` }}",
        "vboxmanage": [          
            [ "modifyvm", "{{.Name}}", "--cpus", "1" ],
            [ "modifyvm", "{{.Name}}", "--memory", "2048" ],
            [ "modifyvm", "{{.Name}}", "--clipboard", "bidirectional" ],            
            [ "modifyvm", "{{.Name}}", "--draganddrop", "bidirectional" ],
            [ "modifyvm", "{{.Name}}", "--boot3", "disk" ],
            [ "modifyvm", "{{.Name}}", "--audio", "none" ],  
            [ "modifyvm", "{{.Name}}", "--nic1", "intnet" ],  
            [ "modifyvm", "{{.Name}}", "--nic2", "null" ]
          ],
        "guest_os_type": "Ubuntu_64",
        "iso_url": "{{ user `iso_url` }}",
        "iso_checksum": "{{ user `iso_checksum` }}",
        "iso_checksum_type": "md5",
        "disk_size": "{{ user `disk_size` }}",
        "ssh_username": "{{ user `ssh_username` }}",
        "ssh_password": "{{ user `ssh_password` }}",
        "ssh_timeout": "{{ user `ssh_timeout` }}",
        "guest_additions_mode": "attach",
        "headless": "{{ user `headless` }}",
        "http_directory": "http",
        "boot_wait": "5s",
        "boot_command": [
          "<enter><wait5>",
          "<esc><enter><wait5>",
          "preseed/url=http://{{.HTTPIP}}:{{.HTTPPort}}/ubuntu/{{user `preseed_file`}} ",
          "<enter>"
        ],
        "shutdown_command": "echo 'packer' | sudo -S shutdown -P now"
      }
    ],
    "post-processors": [
      {
        "type": "vagrant",
        "output": "C:/Users/{import/automation/packer/boxes/ubuntu/{{ user `box_name` }}.box"
      }
    ],
    "variables": {
      "headless": "false",
      "iso_checksum": "{{ user `iso_checksum` }}",
      "iso_url": "{{ user `iso_url` }}",
      "disk_size": "256000",
      "alias": "packervm",
      "box_name": "ubuntu_custom",
      "ssh_timeout": "10m",
      "ssh_username": "{{ user `ssh_username` }",
      "ssh_password": "packer",
      "preseed_file":"temp.cfg"

    }
  }

第2步:附加到容器并运行:

RUN Invoke-WebRequest -OutFile c:\rtools_setup_x64.exe -Uri https://aka.ms/vs/15/release/RemoteTools.amd64ret.enu.exe;

我的问题: 如何在Dockerfile中集成第2步? 我试过这样但它不起作用:

$>c:/rtools_setup_x64.exe /install /quiet; & 'C:\Program Files\Microsoft Visual Studio 15.0\Common7\IDE\Remote Debugger\x64\msvsmon.exe' /nostatus /silent /noauth /anyuser /nosecuritywarn /port 4020

1 个答案:

答案 0 :(得分:0)

您可以使用以下命令从dockerfile安装远程调试器:

RUN Invoke-WebRequest -Uri https://aka.ms/vs/15/release/RemoteTools.amd64ret.enu.exe -OutFile vs_remotetools.exe ; \
.\vs_remotetools.exe /install /quiet