Skip to content

Instantly share code, notes, and snippets.

@robearlam
Last active August 11, 2019 02:57
Show Gist options
  • Save robearlam/9db4e18067d89d82bbb17ed5df754aa3 to your computer and use it in GitHub Desktop.
Save robearlam/9db4e18067d89d82bbb17ed5df754aa3 to your computer and use it in GitHub Desktop.
Using VSCode to debug a .NETCore application running inside a Docker container
version: "3"
services:
myapp:
container_name: myapp
build:
context: .
FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /app
# copy csproj and restore as distinct layers
COPY *.sln .
COPY myapp/*.csproj ./myapp/
RUN dotnet restore
# copy everything else and build app
COPY myapp/. ./myapp/
WORKDIR /app/myapp
RUN dotnet publish -c Debug -o out
FROM microsoft/dotnet:2.2-aspnetcore-runtime AS runtime
WORKDIR /app
COPY --from=build /app/myapp/out ./
RUN apt-get update
RUN apt-get install -y --no-install-recommends apt-utils
RUN apt-get install -y curl unzip procps
RUN curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l /publish/vsdbg;
ENTRYPOINT ["dotnet", "myapp.dll"]
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Docker Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickRemoteProcess}",
"sourceFileMap": {
"/app": "${workspaceFolder}"
},
"pipeTransport": {
"pipeProgram": "docker",
"pipeArgs": [ "exec", "-i", "myapp" ],
"debuggerPath": "/publish/vsdbg/vsdbg",
"pipeCwd": "${workspaceRoot}",
"quoteArgs": false
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment