3
votes

I'm trying to run .NET Core WebApi project in debug configuration using Dockerfile. I've created api application using template in Rider (the one with ValuesController), created dockerfile like below. Running the app without debugging works fine both from regular launch profile and the dockerfile one. Debugging from the regular launch profile works fine, but when I'm trying to run the debug configuration using the dockerfile I'm getting error: /riderDebugger/runtime.sh: exec: line 40: /riderDebugger/linux-x64/mono/bin/mono-sgen: not found. I can see that Rider adds the volume bindings /riderDebugger and /riderLogs when running debug configuration, already checked that the host path for the /riderDebugger contains the file that the runtime.sh is trying to run.

Also I can't run the image created from the dockerfile below with command override, for example creating the image with command docker image build -t example-api-manual --no-cache . and running it with docker container run -it --rm example-api-manual sh does not start the sh but just runs the image with default command like there is no command override. So because of this I'm not even able to get into the container and check what's wrong with those volume bindings.

I'm using macOS Catalina 10.15.2 and JetBrains Rider 2019.3.1.

Dockerfile:

FROM mcr.microsoft.com/dotnet/core/sdk:2.2-alpine AS build
WORKDIR /app

COPY *.csproj ./
RUN dotnet restore

COPY ./. ./
WORKDIR /app
RUN dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-alpine AS runtime
WORKDIR /app
COPY --from=build /app/out ./
ENTRYPOINT [ "dotnet", "ExampleApi.dll" ]
1

1 Answers

5
votes

The alpine image is currently not working with the internal rider docker debugger. Please use the Debian image. Just remove the -alpine tag and you are good to go :-)

FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build
WORKDIR /app

COPY *.csproj ./
RUN dotnet restore

COPY ./. ./
WORKDIR /app
RUN dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/core/aspnet:2.2 AS runtime
WORKDIR /app
COPY --from=build /app/out ./
ENTRYPOINT [ "dotnet", "ExampleApi.dll" ]

Edit: I'm using 10.14.6 Mojave with SIP (System Integrity Protection) disabled. Please let me know if the provided answer works for you. Thank you very much!