Remote connection to docker

Questions about YourKit .NET Profiler
Locked
ukhl
Posts: 4
Joined: Wed Oct 27, 2021 7:13 am

Remote connection to docker

Post by ukhl »

Hi,

where i can found full manual how to remote connect to docker app?


I tried cretate Dockerfile

FROM mcr.microsoft.com/dotnet/aspnet:5.0

RUN apt-get update && apt-get install -y wget && apt-get install -y unzip

RUN wget https://www.yourkit.com/dotnet/download ... 3-b101.zip -P /tmp/ && \
unzip /tmp/YourKit-NetProfiler-2021.3-b101.zip -d /usr/local && \
rm /tmp/YourKit-NetProfiler-2021.3-b101.zip


ENV CORECLR_PROFILER={MY_GUID}
ENV CORECLR_ENABLE_PROFILING=1
ENV CORECLR_PROFILER_PATH_64=/usr/local/YourKit-NetProfiler-2021.3-b101/bin/linux-x86-64/libynpagent.so
ENV YNP_STARTUP_OPTIONS=listen=all,recursive

# ASP.NET Core doesn't handle SIGTERM properly but instead handles SIGINT for graceful shutdown
STOPSIGNAL SIGINT

WORKDIR /app
COPY binaries/engine /app
ENTRYPOINT ["dotnet", "MyApp.dll"]

also i run this image with -p 10001:10001 option

status give me
Name | PID | User | Profiler Agent | Port
-------------------+----------+------+----------------+------
MyApp.dll | 1 64-bit | root | Not loaded |

and remote connection does not working
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Remote connection to docker

Post by Anton Katilin »

Hello,

Please ensure the GUID is specified.

Instead of

ENV CORECLR_PROFILER={MY_GUID}

please do something like

RUN 'export CORECLR_PROFILER=$(cat /usr/local/YourKit-NetProfiler-2021.3-b101/guid.txt)'
Ilia
Posts: 3
Joined: Mon Oct 15, 2018 8:12 pm

Re: Remote connection to docker

Post by Ilia »

Hello,

Your Dockerfile looks almost right - top level profiler directory doesn't contain build number.

By the way, if you want to and open specific port you can use "port=" startup option. And to connect to the profiler agent in Docker container from the machine where it runs, you have to add remote connection to the localhost and set the port, as you won't see it in "Local applications", which relies on shared memory.

Unfortunately there's bug in version 2021.3 which causes deadlock on Linux with Server GC, so it should be disabled while profiling. For example you can set environment variable COMPlus_gcServer to 0.
Other methods are described here: https://docs.microsoft.com/en-us/dotnet ... -collector

The bug will be fixed in the next profiler version, which will also support .NET 6.

This should work:

Code: Select all

# Profiler GUID is unique for each profiler build - this one is for b101
ENV CORECLR_PROFILER="{17154956-38B7-4D11-AEDD-AE33A5E1DA27}"
ENV CORECLR_ENABLE_PROFILING="1"
ENV CORECLR_PROFILER_PATH_64="/usr/local/YourKit-NetProfiler-2021.3/bin/linux-x86-64/libynpagent.so"
ENV YNP_STARTUP_OPTIONS="listen=all,port=10001"
# Workaround for profiler bug
ENV COMPlus_gcServer="0"
ukhl
Posts: 4
Joined: Wed Oct 27, 2021 7:13 am

Re: Remote connection to docker

Post by ukhl »

Ilia wrote:Hello,

Your Dockerfile looks almost right - top level profiler directory doesn't contain build number.

By the way, if you want to and open specific port you can use "port=" startup option. And to connect to the profiler agent in Docker container from the machine where it runs, you have to add remote connection to the localhost and set the port, as you won't see it in "Local applications", which relies on shared memory.

Unfortunately there's bug in version 2021.3 which causes deadlock on Linux with Server GC, so it should be disabled while profiling. For example you can set environment variable COMPlus_gcServer to 0.
Other methods are described here: https://docs.microsoft.com/en-us/dotnet ... -collector

The bug will be fixed in the next profiler version, which will also support .NET 6.

This should work:

Code: Select all

# Profiler GUID is unique for each profiler build - this one is for b101
ENV CORECLR_PROFILER="{17154956-38B7-4D11-AEDD-AE33A5E1DA27}"
ENV CORECLR_ENABLE_PROFILING="1"
ENV CORECLR_PROFILER_PATH_64="/usr/local/YourKit-NetProfiler-2021.3/bin/linux-x86-64/libynpagent.so"
ENV YNP_STARTUP_OPTIONS="listen=all,port=10001"
# Workaround for profiler bug
ENV COMPlus_gcServer="0"

Thanks, it helps
Locked