Runnable Spring Boot JAR + Docker: Enable JMX

When you run a Spring Boot app in a Docker container, you can’t access JMX endpoints using the basic config.

Command to use to start your Spring Boot application inside your Docker container:

java \
-Djava.rmi.server.hostname=127.0.0.1 \
-Dcom.sun.management.jmxremote.port=8089 \
-Dcom.sun.management.jmxremote.rmi.port=8089 \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.authenticate=false \
-jar app.jar

Then you just have to map the port 8089 in a port of your host machine (let’s say 8089), and you can access it via Visual VM at “localhost:8089”.

Leave a Reply

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

WordPress.com Logo

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

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s