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

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?
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: 6062
Joined: Wed Aug 11, 2004 8:37 am

Return to Java Profiler

Who is online

Users browsing this forum: Google [Bot] and 1 guest


YourKit uses cookies and other tracking technologies to improve your browsing experience on our website, to show you personalized content and targeted ads, to analyze our website traffic, and to understand where our visitors are coming from.

By browsing our website, you consent to our use of cookies and other tracking technologies in accordance with the Privacy Policy.