Dockerized Java Application Performance Analysis

Using JMX to analyse a Java Virtual Machine (JVM) within a local or remote docker image. The example below explores how to analyse a Tomcat Server (version 7) running in a docker instance using Oracle JRockit Mission Control (JMC)

Screen Shot 2015-12-12 at 12.46.11 am

Your JRockit Mission Control is here

  • OSX : /Library/Java/JavaVirtualMachines/{JDK}/Contents/Home/bin/”
  • Windows: “JDK_HOME/bin/”


Step-by-step guide

Add the steps involved:

  1. Determine your docker machines IP, for example on our machine we did
    1. Do `docker-machine active` to see the active machines 

      1. On my machine this returned `default` as the machine name

    2. Do `docker-machine ip default` to see the IP of the machine named ‘default`

      1. On my machine this returned ``

        Screen Shot 2015-12-12 at 12.39.53 am.png

  2. Create a script with the JMX options
    1. Set the `CATALINA_OPTS` env variable as shown below
    2. Set the “java.rmi.server.hostname” to the IP obtained in step (1.b) above
    3. Please note that we are not using SSL nor JMX Remote Authentication – so the config below is for DEV only 
  3. Use the script within the tomcat runtime
    1. In your Dockerfile you can do
      1. `ADD /apache-tomcat-7.0.62/bin/`  when using an Apache Tomcat image
      2. or `ADD /camunda/bin/` when using Camunda (embedded or standalone)

    2. You can add this at runtime as well using
      1. `-v ${PWD}/`when using an Apache Tomcat image
      2. or `-v ${PWD}/` when using Camunda (embedded or standalone)
  4. Start the Docker container and map JMX ports
    1. To the `docker run` command add the following ports
      1. The JMX Remote and RMI Port  `-p 1898:1898`
      2. and  TCP Transport Port `-p 62911:62911`
  5. Validate the Docker container is exposing the ports
    1. Do a `docker ps ` and example your image’s ports
    2. Do a `docker exec -i -t` and validate the contents of your file to confirm the  CATALINA_OPTS  are set
      1. NOT doing will throw you off if the is not copied! Simple exposing the Docker container ports does not mean the JVM allows JMX connections
      2. Example: Docker Exec command to view the contents of the file for apache-tomcat-7.0.62 
  6. Run the JRockit Mission Control
    1. Comes with the JDK
    2. On a Mac you can find it here “/Library/Java/JavaVirtualMachines/{JDK}/Contents/Home/bin/”  and the executable is called “jmc”

  7. Add a Remote connection in JMC

    1. File – > Connect
    2. Provide the JMX Connection properties
      1. Host is the Docker Machine IP we obtained in Step 1 above
      2. Port is the JMX Remote Port, for example: 1898 in Step 2 above
      3. Name the Connection “Docker-<image-name>”
      4. Test the Connection


    3. Your JVM shows up in JRockit
  8. Start JMX Console and view JVM metrics


See more details on how to use the JRockit JVM tool here


Leave a Comment

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s