Docker Community Forums

Share and learn in the Docker community.

Profiling ASP.NET core application in Linux Docker container

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?

When i checked the dependency of libcoreclrmonitor.so file got the following,

root@15997507dac6:/app# **ldd libegcoreclrmonitor.so**
linux-vdso.so.1 (0x00007fff49ffe000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fed800da000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fed7ff15000)
/lib64/ld-linux-x86-64.so.2 (0x00007fed8074c000)

Can you please help me on this. How to load my profiler file in docker container?