Profiling ASP.NET core application in Linux Docker container

Duraikannu Jeyamani 6 Reputation points
2021-11-09T12:33:27.07+00:00

I have created my OWN .NET Core profiler to profile ASP.net core application running on Linux environment.
It was working as expected and able to get the details from my profiler.

Now, I wants to profiler .NET core application running in Docker container(Linux).
The application running successfully in container environment when there is no profiler enabled.
If we enable profiler in the container environment its getting crashed.

This is my Dockerfile,

***<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
    FROM mcr.microsoft.com/dotnet/core/aspnet:3.1.20-buster-slim AS base
    WORKDIR /app
    EXPOSE 80
    FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
    WORKDIR /src
    COPY ["DockerDemo.csproj", ""]
    RUN dotnet restore "./DockerDemo.csproj"
    COPY . .
    WORKDIR "/src/."
    RUN dotnet build "DockerDemo.csproj" -c Release -o /app/build
    FROM build AS publish
    RUN dotnet publish "DockerDemo.csproj" -c Release -o /app/publish
    COPY libcoreclrmonitor.so /app/publish
    COPY CorProfiler.so /app/publish
    FROM base AS final
    WORKDIR /app
    COPY --from=publish /app/publish .
    ENTRYPOINT ["dotnet", "DockerDemo.dll"]
    ENV CORECLR_PROFILER="{950A85A8-9E1B-4611-BEA6-E5A20686387E}"
    ENV CORECLR_ENABLE_PROFILING=1
    ENV CORECLR_PROFILER_PATH_64="/app/libcoreclrmonitor.so"
    ENV LD_LIBRARY_PATH="/app"
    <!-- end snippet -->***

Here, libcoreclrmonitor.so is my profiler file developed using ICorProfilerCallback API.
When we run "docker run" command to start the container its getting crashed.

How to solve this problem ? What I missed here ?
How to load profiler in docker environment?

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,337 questions
0 comments No comments
{count} votes