Created
September 14, 2015 09:20
-
-
Save PierreMage/319c6c3d8154bc0e0360 to your computer and use it in GitHub Desktop.
boot2docker-jmxremote-example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM java:8 | |
COPY Main.java / | |
RUN javac Main.java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
public static void main(String[] args) { | |
while (true) {} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
JMX_PORT=${1:-1099} | |
IMAGE_NAME=boot2docker-jmxremote-example | |
CONTAINER_NAME=$IMAGE_NAME | |
# Build docker image | |
docker build -t $IMAGE_NAME . | |
# Run docker container | |
docker run --name $CONTAINER_NAME -d --expose $JMX_PORT -p $JMX_PORT:$JMX_PORT $IMAGE_NAME \ | |
java -Dcom.sun.management.jmxremote.port=$JMX_PORT \ | |
-Dcom.sun.management.jmxremote.authenticate=false \ | |
-Dcom.sun.management.jmxremote.ssl=false \ | |
-Dcom.sun.management.jmxremote.rmi.port=$JMX_PORT \ | |
-Djava.rmi.server.hostname=$(boot2docker ip) \ | |
Main | |
STATUS=$? | |
# Start visualvm or jconsole | |
if [ $STATUS -eq 0 ]; then | |
jvisualvm --openjmx $(boot2docker ip):$JMX_PORT | |
# jconsole $(boot2docker ip):$JMX_PORT | |
fi | |
# Delete docker container | |
docker rm -f $CONTAINER_NAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment