question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

breakpoints in vscode not working as expected when debugging in docker container

See original GitHub issue

I’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:

image

Also, when I add breakpoints they are not shown in code editor:

image image

When i debug locally everything works as expected:

image

Expected behavour:

I should be able to see breakpoints in code editor and inspect values directly in code.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
itowlsoncommented, Jun 4, 2020

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.

0reactions
lstocchicommented, Jun 4, 2020

Cooool 👍

Closing here then. Feel free to reopen this issue if you face it again. Thank you everyone!!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

breakpoints in vscode not working as expected when ... - GitHub
I'm trying to debug .netcore mvc application running in a docker container with kubernetes. I've installing vsdbg inside a container and run it....
Read more >
GDB is no longer hitting breakpoints in VS Code within docker ...
json and I ran gdb and debugged in my code successfully until something happened and all breakpoint became "gray" with the such message:...
Read more >
Debug an app running in a Docker container
Debug an app running in a Docker container, using Visual Studio Code.
Read more >
Debugging Go Inside Docker, Using Visual Studio Code and ...
There have been many times in my career or when working on personal projects, that I have needed some open-source executables to help...
Read more >
Debugging - Business Central | Microsoft Learn
With Visual Studio Code and the AL Language extension, ... When the program flow reaches the breakpoint, the debugger stops execution until ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found