Build ubuntu environment with docker and perform remote debugging from Visual Studio 2017.
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
$ docker-compose build
$ docker-compose up -d
SSH
$ docker exec -it docker_dev bash
VisualStudio
--New> Visual C ++> Cross Platform> Linux --If not, select "Development of Linux with C ++" from the installer and install it.
--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
--Rebuild the solution --Build> Rebuild Solution --Display of Linux console --Debug> linux console