Fully featured low overhead profiler for Java EE and Java SE platforms.
Performance monitoring and profiling of Jenkins, TeamCity, Gradle, Maven, Ant, JUnit and TestNG.
Easy to use performance and memory profiler for .NET framework.

Yourkit Agent - Docker Container

Moderators: Vladimir Kondratyev, Anton Katilin

Yourkit Agent - Docker Container

Postby gajendra » Sun Mar 18, 2018 6:35 am

I have an application running in Docker containers needs profiling. There is no way for me to run this application outside of docker because of the environment.

Is there any proven way of doing this?
gajendra
 
Posts: 1
Joined: Sun Mar 18, 2018 6:22 am

Re: Yourkit Agent - Docker Container

Postby Anton Katilin » Mon Mar 19, 2018 8:00 am

To profile a Java application or a server running in a docker container, you should run it with the profiler agent, and then use remote profiling in the profiler UI, as described below.

On Docker side

(1) Add few lines to your image's Dockerfile.

(1.1) Install YourKit Java Profiler agents:
Code: Select all
RUN wget https://www.yourkit.com/download/YourKit-JavaProfiler-2017.02-b75.zip -P /tmp/ && \
  unzip /tmp/YourKit-JavaProfiler-2017.02-b75.zip -d /usr/local && \
  rm /tmp/YourKit-JavaProfiler-2017.02-b75.zip


(1.2) If you use Alpine Linux install libc6-compat:
Code: Select all
RUN apk add --no-cache libc6-compat


(1.3) Expose the profiler agent port.

For example, if you specify the port with the agent startup option port=10001 (see below), add the following line.
Code: Select all
EXPOSE 10001


Note: we use the same example port 10001 throughout these instructions. If you decide to change it, please ensure you have changed it everywhere.

(1.4) Load the agent to the JVM by adding the Java command line option -agentpath.

For example, if you start your application with
Code: Select all
java -jar my-app.jar


...do it like this:
Code: Select all
java -agentpath:/usr/local/YourKit-JavaProfiler-2017.02/bin/linux-x86-64/libyjpagent.so=port=10001 -jar my-app.jar


Please find detailed description of how to specify -agentpath and choose the agent startup options in https://www.yourkit.com/docs/java/help/agent.jsp

(2) After modifying Dockerfile don't forget to build the container.

(3) While running your docker container make the agent port visible with the option -p:
Code: Select all
 docker run -p 10001:10001 your-docker


Connect to the profiled application

When the application is running in the container, remotely connect to it from the profiler UI to perform profiling: https://www.yourkit.com/docs/java/help/ ... jsp#remote

Note: if you're running docker locally on your developer machine, connect to localhost.
Anton Katilin
 
Posts: 5808
Joined: Wed Aug 11, 2004 8:37 am


Return to Java Profiler

Who is online

Users browsing this forum: No registered users and 15 guests