I have my own hand written Dockerfile/docker-compose files. I start containers from command line. Now I want to attach Visual Studio 2017 (not Visual Studio Code) to my application inside a Docker (Linux-based) container. It seems it should a pretty easy task, but I can't find any information on how to do this.
I read through the guide Off-road Debugging of .NET Core on Linux or OS X from Visual Studio carefully. At first it looked like what I needed - a description on how to remotely debug a .NET Core application running in Linux. But it only tells a part of the story - how to debug via SSH. And just mentions Docker, but it says nothing to how to remotely debug an application inside Docker.
I guess there shouldn't be much specific of Docker here, it's just running vsdbg inside Docker and attaching here. But obviously it's a very common dev use case and it's weird that there's no good information on this.
Surely, there are VS Tools for Docker using which we can easily do debugging of an application inside a Docker container. But for me, VS Tools for Docker are just terrible. Yes, they work seamlessly at first. But it is absolute unclear what is going on under the hood.
It seems that we just can look up what VS Tools for Docker do and try to reproduce that. But it's not very obvious. It adds an additional "debug" YAML file to docker-compose (docker-compose.vs.debug.g.yml) which should do the debugging magic. I tried to add that YAML content to my hand-written docker-compose, run Dockers, but how can I attach Visual Studio?
I get the IP address of my container, tried to find a remote debugger on that IP address and 4022 that Visual Studio can't see anything. Also it's suspicious that file debug.yaml created by Tools for Docker has nothing about exposing the 4022 port as it could be expected.
P.S.: I found a good guide but on Windows containers