title: cannot connect to JMX with Spring Boot and Docker
body: <p>I have a Spring Boot app, containerized, running in Docker Cloud, with the following <code>JAVA_OPTS</code>: </p>
  
  <pre><code>-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
  </code></pre>
  
  <p>when I try to connect to the host with <code>jmc</code>, I get <code>Unnable to connect</code>. This is the url I'm using:</p>
  
  <p><code>service:jmx:rmi:///jndi/rmi://api.name-sta.xxxx.svc.dockerapp.io:1099/jmxrmi</code></p>
  
  <p>I also have the port 1099 exposed in the container.<br>
  What else can I try? </p>
  
  <p><strong>Edit</strong> </p>
  
  <p>This is how I'm starting the container:</p>
  
  <p>Dockerfile:</p>
  
  <pre><code>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"]
  </code></pre>
  
  <p>and the Stackfile:</p>
  
  <pre><code>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
  </code></pre>