Skip to content

Instantly share code, notes, and snippets.

@arogulin
Last active May 29, 2018 07:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arogulin/e050175d8cfdefe8bf25114dfb1a43cf to your computer and use it in GitHub Desktop.
Save arogulin/e050175d8cfdefe8bf25114dfb1a43cf to your computer and use it in GitHub Desktop.
How to profile java app inside docker container on remote host protected by firewall
  1. Restart the app with the following JVM arguments:
-Dcom.sun.management.jmxremote.port=9010
-Dcom.sun.management.jmxremote.rmi.port=9010
-Dcom.sun.management.jmxremote=true
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.local.only=false
  1. Expose port 9010 for that docker container.

  2. Bring up an SSH tunnel to the host, which runs that docker container, to forward all communications through port 9010:

ssh vpn -L 9010:localhost:9010
  1. Start jvisualvm and add new "JMX connection" to "localhost:9010"
  2. "Profile" tab will not be available, because of JMX. But, "Sampling" tab is useful.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment