Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
JVM Profiler with Docker

JProfiler with Docker



DockerFile should have JProfiler installation.

RUN wget <JProfiler file location> -P /tmp/ && \
  tar -xzf /tmp/<JProfiler file> -C /usr/local && \
  rm /tmp/<JProfiler file>

EXPOSE <port>


RUN wget -P /tmp/ && \
  tar -xzf /tmp/jprofiler_linux_9_2.tar.gz -C /usr/local &&\
  rm /tmp/jprofiler_linux_9_2.tar.gz



docker run -p <port>:<port> your-docker 


docker run -p 8849:8849 your-docker 


Run Application with JProfiler Agent

java -jar my-app.jar -agentpath:/usr/local/jprofiler9/bin/linux-x64/<port>


java -jar my-app.jar -agentpath:/usr/local/jprofiler9/bin/linux-x64/

So in the DockerFile, it looks like

ENTRYPOINT ["java -jar","my-app.jar", 
  1. Select 'Profile an application server, locally or remotely'.
  2. If the target application is running on any specific server listed, select it. Otherwise, choose Generic application.
  3. Select Linux X86/AMD64 for Platform of the remote computer on a remote computer.
  4. Select the JVM used in the Docker instance.
  5. To make JProfiler to wait for the application to start and send data, select Wait for a connection from the JProfiler GUI.
  6. Enter the remote address to the Remote address. If it's Docker for Mac, it is localhost. If Docker Machine is used, use the IP of the Docker Machine.
  7. Add the path to the JProfiler on the Docker where the jar file metioned above is using to the Remote installation directory. It looks like /usr/local/jprofiler<version>. e.g.) /usr/local/jprofiler9
  8. Set the port number or use the default (i.e. 8849).

VisualVM with Docker


VisualVM comes with the JDK so it doesn't require any extra installation or payment if JDK is already installed.


The following options should be added to java executable command.<port><port>
-Djava.rmi.server.hostname=<docker ip>

So it should be like

ENTRYPOINT ["java -jar", "app.jar",
  "-Djava.rmi.server.hostname=<docker ip>"]


ENTRYPOINT ["java -jar", "my-app.jar",
  • Docker for Mac uses Hyperkit instead of Docker Machine through VirtualBox so the host location can be just localhost rather than the IP of the Docker Machine. If you're using Docker Machine, use the IP of the machine.


Run jvisualvm which is located at $JAVA_HOME/bin.

  1. File -> Add JMX Connection...
  2. Enter the host and port (e.g. localhost:8849).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.