breakpoints in vscode not working as expected when debugging in docker container
See original GitHub issueI’m trying to debug .netcore mvc application running in a docker container with kubernetes.
I’ve installing vsdbg
inside a container and run it. Here is my dockerfile:
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 5000
ENV ASPNETCORE_URLS=http://*:5000
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /src
COPY ["GraphQLApi.csproj", "."]
RUN dotnet restore "GraphQLApi.csproj"
COPY . .
RUN dotnet build "GraphQLApi.csproj" --no-restore -c Debug -o /app/build
FROM build AS publish
RUN dotnet publish "GraphQLApi.csproj" --no-restore -c Debug -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
# Install the dependencies for Visual Studio Remote Debugger
RUN apt-get update && apt-get install -y --no-install-recommends unzip procps
# Install Visual Studio Remote Debugger
RUN curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l /vsdbg
ENTRYPOINT ["dotnet", "GraphQLApi.dll"]
and this is my deployment yaml:
apiVersion: v1
kind: Service
metadata:
name: test2
labels:
app: test2
spec:
selector:
app: test2
ports:
- nodePort: 30917
port: 8082
protocol: TCP
targetPort: 5000
type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: test2
labels:
app: test2
spec:
replicas: 1
selector:
matchLabels:
app: test2
template:
metadata:
labels:
app: test2
spec:
containers:
- name: test2
image: test2
imagePullPolicy: IfNotPresent
ports:
- containerPort: 5000
Application starts as expected and I’m running Kubernetes: Attach (Attach)
in vscode. Debugger is being attached as expected. So far so good. Unfortunately when I hit a breakpoint vscode is not showing correct breakpoints in editor. App is stopped and I can see correct values in Locals, but I can’t inspect code connected to a breakpoint. Instead when I click a breakpoint in breakpoints list empty file is shown:
Also, when I add breakpoints they are not shown in code editor:
When i debug locally everything works as expected:
Expected behavour:
I should be able to see breakpoints in code editor and inspect values directly in code.
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (3 by maintainers)
Top GitHub Comments
Thanks! I’m going to leave #586 to be a release all by itself because it scares me and I want to be able to roll back quickly and without further impact. I’ll see if it’s quick to fix the conflicts in #704 and take it if I can.
Cooool 👍
Closing here then. Feel free to reopen this issue if you face it again. Thank you everyone!!!