3

I have a Spring Boot app, containerized, running in Docker Cloud, with the following JAVA_OPTS:

-Xmx512m -XX:+UseConcMarkSweepGC -XX:NativeMemoryTracking=summary -Djava.rmi.server.hostname=127.0.0.1 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.rmi.port=1099 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false

when I try to connect to the host with jmc, I get Unnable to connect. This is the url I'm using:

service:jmx:rmi:///jndi/rmi://api.name-sta.xxxx.svc.dockerapp.io:1099/jmxrmi

I also have the port 1099 exposed in the container.
What else can I try?

Edit

This is how I'm starting the container:

Dockerfile:

FROM java:8
VOLUME /chathub
COPY target/chathub-backend-1.0.0.jar app.jar
RUN sh -c 'touch app.jar'
EXPOSE 8080
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-Dspring.profiles.active=docker", "-jar","/app.jar"]

and the Stackfile:

api:
  image: 'luizkowalski/chathub:qa'
  deployment_strategy: every_node
  environment:
    - DATABASE_PASSWORD=xxx
    - 'DATABASE_URL=xxx'
    - DATABASE_USERNAME=xx
    - 'JAVA_OPTS=-Xmx512m -XX:+UseConcMarkSweepGC -XX:NativeMemoryTracking=summary -Djava.rmi.server.hostname=127.0.0.1 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.rmi.port=1099        -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false'
    - MIXPANEL_TOKEN=xxx
  mem_limit: 258m
  ports:
    - '1099:1099'
    - '8080:8080'
  tags:
    - sta
Luiz E.
  • 5,739
  • 7
  • 47
  • 87
  • Can you please show how you are starting the container? (docker run command or compose file) – Andreas Jägle Sep 07 '16 at 21:51
  • @AndreasJägle edited – Luiz E. Sep 07 '16 at 21:57
  • 1
    did you solve this issue meanwhile? There are some topics like http://stackoverflow.com/questions/29412072/how-to-access-spring-boot-jmx-remotely and http://stackoverflow.com/questions/856881/how-to-activate-jmx-on-my-jvm-for-access-with-jconsole - but it seems there still is a second port required or the port mappings in docker interfere with rmi? I can connect to JMX when directly running the jar, but not if its started in a docker container. The jmx port is reachable / open but jconsole does not properly connect. – wemu Feb 08 '17 at 11:59
  • 3
    should be http://stackoverflow.com/questions/2011311/running-java-with-java-opts-env-variable - `JAVA_OPTS` is not evaluated by anything in your setup: - your `ENTRYPOINT` would need to be like `["java", "$JAVA_OPTS", "-D..`. `JAVA_OPTS` is just a conventional place to put them and there are usually startup scripts that evaluate them. But not when you start via `java -jar ..`. The JVM itself does not care about that environment variable. – zapl Feb 27 '17 at 12:25

0 Answers0