-
Notifications
You must be signed in to change notification settings - Fork 531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Debug Container #56
Comments
@galvesribeiro PRs are always welcome! I'm not too familiar with the VS2017 experience, so any feedback/thoughts you have on how to improve this extension would be awesome. |
Hello @lostintangent, thanks for the promptly reply. Have a look on this post https://blogs.msdn.microsoft.com/webdev/2016/11/16/new-docker-tools-for-visual-studio/ It show how it work on Visual Studio. Basically you right click a project or solution and add Docker support to it. Once it is added, just hit F5 and all the "magic" happens and you have a debugger attached to your target container. On VS2017 it even support multiple containers which are running on |
For Node, the extension generates a docker-compose.debug.yml file that will open both the site and debugger ports and run node with the debug switch. you could automate the debug process by running docker-compose up on the yml file as a pre launch task and then VS Code should be able to attach to it. For C#, the same pattern could be used... generate the right task file, docker-compose.debug.yml, and then connecting them in launch.json. |
@lostintangent look at my repo here: https://github.com/spboyer/dockerdebugapp |
Cool! |
Guys I just illustrated the docker-compose as an example. Your approaches work well for a single project, without a solution and that has a single container to attach. The idea is to press F5 and attach a debugger to all services inside docker-compose file. After multiple try and error, I found a better way that doesn't rely on scripts/hacks to suppress the lack of the feature in VSCode. This is a sample version: '3.1'
services:
repository-api:
image: repository-api:debug
build:
context: ./src/QUBIX.Repository.API/bin/PublishOutput/
dockerfile: Dockerfile.debug
ports:
- "10200:10200"
environment:
- ASPNETCORE_ENVIRONMENT=Development
volumes:
- ./src/QUBIX.Repository.API/bin/PublishOutput/:/app
- ~/.nuget/packages:/root/.nuget/packages:ro
depends_on:
- repository-silo
repository-silo:
image: repository-silo:debug
build:
context: ./src/QUBIX.Repository.Silo/bin/PublishOutput/
dockerfile: Dockerfile.debug
environment:
- QUBIX_REPOSITORY_MBR_CS
volumes:
- ./src/QUBIX.Repository.Silo/bin/PublishOutput/:/app
- ~/.nuget/packages:/root/.nuget/packages:ro
repository-reader-silo:
image: repository-reader-silo:debug
build:
context: ./src/QUBIX.Repository.Reader.Silo/bin/PublishOutput/
dockerfile: Dockerfile.debug
environment:
- QUBIX_REPOSITORY_READER_MBR_CS
- QUBIX_REPOSITORY_READER_DOCDB_EP
- QUBIX_REPOSITORY_READER_DOCDB_KEY
volumes:
- ./src/QUBIX.Repository.Reader.Silo/bin/PublishOutput/:/app
- ~/.nuget/packages:/root/.nuget/packages:ro This is the
Note that I have multiple services in it but none of them has the debugger port open. Note also that the Once in a day, when I start working on the project, I just open a terminal into the solution directory and Once you have all the containers up and running, you need to configure your VSCode to get it to debug the containers. This is my {
"version": "0.1.0",
"isShellCommand": true,
"command": "dotnet",
"args":[],
"tasks": [
{
"taskName": "publish",
"args": [
"${workspaceRoot}/QUBIX-Repository.sln", "-c", "Debug", "-o", "bin/PublishOutput"
],
"isBuildCommand": true,
"problemMatcher": "$msCompile"
}
]
} Note that instead of Now this is my {
"version": "0.2.0",
"configurations": [
{
"name": "Repository-Silo",
"type": "coreclr",
"request": "launch",
"cwd": "/app",
"program": "/app/QUBIX.Repository.Silo.dll",
"sourceFileMap": {
"/app": "${workspaceRoot}/src/QUBIX.Repository.Silo"
},
"pipeTransport": {
"pipeProgram": "/bin/bash",
"pipeCwd": "${workspaceRoot}",
"pipeArgs": [
"-c",
"docker exec -i qubixrepository_repository-silo_1 /clrdbg/clrdbg --interpreter=mi"
]
}
},
{
"name": "Repository-API",
"type": "coreclr",
"request": "launch",
"cwd": "/app",
"program": "/app/QUBIX.Repository.API.dll",
"sourceFileMap": {
"/app": "${workspaceRoot}/src/QUBIX.Repository.API"
},
"pipeTransport": {
"pipeProgram": "/bin/bash",
"pipeCwd": "${workspaceRoot}",
"pipeArgs": [
"-c",
"docker exec -i qubixrepository_repository-api_1 /clrdbg/clrdbg --interpreter=mi"
]
}
},
{
"name": "Repository-Reader-Silo",
"type": "coreclr",
"request": "launch",
"cwd": "/app",
"program": "/app/QUBIX.Repository.Reader.Silo.dll",
"sourceFileMap": {
"/app": "${workspaceRoot}/src/QUBIX.Repository.Reader.Silo"
},
"pipeTransport": {
"pipeProgram": "/bin/bash",
"pipeCwd": "${workspaceRoot}",
"pipeArgs": [
"-c",
"docker exec -i qubixrepository_repository-reader-silo_1 /clrdbg/clrdbg --interpreter=mi"
]
}
},
{
"name": "Repository-Reader-API",
"type": "coreclr",
"request": "launch",
"cwd": "/app",
"program": "/app/QUBIX.Repository.Reader.API.dll",
"sourceFileMap": {
"/app": "${workspaceRoot}/src/QUBIX.Repository.Reader.API"
},
"pipeTransport": {
"pipeProgram": "/bin/bash",
"pipeCwd": "${workspaceRoot}",
"pipeArgs": [
"-c",
"docker exec -i qubixrepository_repository-reader-api_1 /clrdbg/clrdbg --interpreter=mi"
]
}
}
]
} Now what is happening here? Remember that our publishOutput is mapped to This way, when you press stop in a debugger session, the command that exit is the Note that there is no external script or extension at all. All you need is VSCode, C# extension and Docker installed. That works perfectly! 💃 Now the downside 😞
The desired experience:
Does it make sense guys? How can we achieved that experience? Thanks! |
@galvesribeiro |
@Shawn-Fan multi-services is something not supported by the debugger out-of-the-box unfortunately. Neither is multi-instance of the same service as well (very useful in truly distributed applications). If you follow my steps in this issue, you can start all the debug containers from the I still think MSFT must allow us to attach the debugger to multiple services and multiple instances out-of-the-box. What I did was a hack to workaround the debugger limitation. |
@galvesribeiro |
Both VS2017 and VS for Mac have the same limitation regarding Docker debugging experience as VSCode... |
first of all thanks to @galvesribeiro for the detailed information he shared here. It was really helpful. For people who is looking to debug aspnetcore 2.0 from vscode I had to do some minimal tweaks to the Dockerfile + launch.json:
Important: everything between <> needs to be filled with data from your app
Happy debugging! |
@galvesribeiro - great work, thanks for sharing. Do you, by chance have an example Dockerfile from one of your service projects - ie. repository-api Thanks |
@mmacneil thanks. The debug image is the one I posted here. The runtime image is essentially an empty image inheriting from a microsoft/dotnet runtime-only image and the entrypoint is |
Thank you @galvesribeiro, that makes sense. I was thinking somehow you were merging Dockerfile.debug and the runtime image as I have seen that mentioned elsewhere but I see in this case there are 2 separate containers for debug and runtime. |
#500 added preview support for (single project) ASP.NET .NET Core debugging (a la VS). I'd love to know if this gets you closer to what you want and, more importantly, if not, what else is needed. |
@philliphoff was it released to VSCode? |
@galvesribeiro Sorry, perhaps I got a little ahead of myself. The PR is merged to |
Ahh cool. I hope it get in soon at least on Insiders build. Will report back my findings. Thanks!
Get Outlook for iOS<https://aka.ms/o0ukef>
…________________________________
From: Phillip Hoff <notifications@github.com>
Sent: Friday, October 19, 2018 6:07:29 PM
To: Microsoft/vscode-docker
Cc: Gutemberg Ribeiro; Mention
Subject: Re: [Microsoft/vscode-docker] Debug Container (#56)
@galvesribeiro<https://github.com/galvesribeiro> Sorry, perhaps I got a little ahead of myself. The PR is merged to master, but it's not yet been released.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#56 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AEfuOIZ_mCzxwQXaP4-G0-CxwNrEhzD0ks5umj8RgaJpZM4LwWjB>.
|
@galvesribeiro , we're closing this bug based on the PR #500. File a new bug if you run into any issues. :-) |
Cool @PrashanthCorp I didn't had time myself to test it as I promised. Did it found its way to the release build of VSCode? Is there are doc/guide on how to proper use it and what should we expect from it? Thanks! |
@galvesribeiro Take a look at https://github.com/Microsoft/vscode-docker#debugging-net-core-preview, thanks! cc @philhoff |
Thanks @StephenWeatherford Just saw that... However, it still struggle in a single-container debug :( No compose or kubernetes support... |
Hello guys,
I would like to know if this extension would accept a PR adding debugging capabilities for a container...
Initially the idea is to make it debug .Net Core applications that are hosted in (multiple) containers and the debugger could be eventually extended to support other types of applications like node.js for example...
If that is the case, I can work on the .Net Core part initially and later on extend it for other techs.
The idea is to make something similar to the experience we have on VS2017 and docker tooling there where you can add the initial docker files (this extension does the very basic already), create the whole infra from the docker (compose) files and then attach a debugger to it.
How does it sound?
Thanks
The text was updated successfully, but these errors were encountered: