[DOCKER] Remote debugging with Visual Studio 2017

things to do

Build ubuntu environment with docker and perform remote debugging from Visual Studio 2017.

Prepare a container for remote debugging

dockerfile


FROM ubuntu:16.04

#Various installations
RUN apt-get update
RUN apt-get install -y openssh-server sudo bash-completion g++ gdb gdbserver rsync git
#Create directory for SSH
RUN mkdir /run/sshd
#Add user
RUN useradd -m -s /bin/bash ubuntu && gpasswd -a ubuntu sudo
#Set password
RUN echo 'ubuntu:ubuntu' | chpasswd

#Published port 22
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]

docker-compose


version: '2.3'
services:
  dev:
    build: .
    ports:
    - "2222:22"
    volumes:
    - ../volume:/tmp/data

Build image / launch container

$ docker-compose build
$ docker-compose up -d

SSH

$ docker exec -it docker_dev bash

VisualStudio

Prepare a project to debug

--New> Visual C ++> Cross Platform> Linux --If not, select "Development of Linux with C ++" from the installer and install it.

Settings on the Visual Studio side

--Specify the connection destination --Tools> Options> Cross-Platform> Connection Manager> Add --Host name: Remote destination IP (localhost) --Port: Port mapped to port 22 (2222) --User name: Guest OS user name (ubuntu) --Authentication type: Password --Password: Password set above (ubuntu)

() Is the value when set above

debug

--Rebuild the solution --Build> Rebuild Solution --Display of Linux console --Debug> linux console

Recommended Posts

Remote debugging with Visual Studio 2017
Remote debugging in Visual Studio (Linux)
Try debugging Python on Raspberry Pi with Visual Studio.
Java with Visual Studio Code (Part 2)
Edit files directly on Linux with Visual Studio Code Remote SSH
Build Python development environment with Visual Studio Code
Debugging pipelines with metaflow
Easy debugging with ipdb
Let's do Linux System Programming with Visual Studio Code and Azure! (From helloworld to nginx development and remote debugging)
Preparing to use Tensorflow (Anaconda) with Visual Studio Code
Python development environment with Windows + Anaconda3 + Visual Studio Code
Python development environment with Windows + Python + PipEnv + Visual Studio Code
Japanese output when dealing with python in visual studio
Execute C ++ functions from Python with Pybind11 (for Windows & Visual Studio Code people) Debugging
Problems and solutions for using the remote debugging environment for Linux apps in Visual Studio 2017
Install numpy in Visual Studio 2019
Remote L Chika with pigpio
Set up a Python development environment with Visual Studio Code
Debugging with pdb in Python
Useful when debugging with TouchDesigner
Bottle Pug in Visual studio 2019
Python development in Visual Studio 2017
Python development in Visual Studio
Try to create a python environment with Visual Studio Code & WSL
Build jupyter notebook environment with Visual Studio Code (VS Code) Mac version
Visual Studio Code may be good
Try using PyCharm's remote debugging feature
Automation of remote operations with Fabric
Use Jupyter Notebook with Visual Studio Code on Windows 10 + Python + Poetry + pyenv-win
Create a Python development environment on Windows (Visual Studio Code remote WSL).