0

I am using visualvm tool and trying to connect to my remote server ubuntu(14.04). In ubuntu my application is running on Docker. The Dockerfile looks like-

FROM anapsix/alpine-java:8_jdk
MAINTAINER user
ENV OFFLINE_DB_USERNAME abc123
ENV OFFLINE_DB_URL jdbc:mysql://x.x.x.x:xxxx/%s?useLegacyDatetimeCode=false&useTimezone=true&serverTimezone=UTC
ENV OFFLINE_DB_SERVER_URL jdbc:mysql://x.x.x.x:xxxx/offlineserver?useLegacyDatetimeCode=false&useTimezone=true&serverTimezone=UTC
ENV OFFLINE_DB_PASSWORD password123
CMD ["java", "-Dcom.sun.management.jmxremote","-Dcom.sun.management.jmxremote.port=9990", "-Dcom.sun.management.jmxremote.rmi.port=9991" "-Dcom.sun.management.jmxremote.local.only=false", "-Dcom.sun.management.jmxremote.authenticate=false","-Dcom.sun.management.jmxremote.ssl=false", "-Djava.rmi.server.hostname=x.x.x.x"
COPY sampleproject.jar /home/ubuntu/test/sampleproject.jar
CMD ["java","-jar","/home/ubuntu/test/sampleproject.jar"]
Expose 9990

I executed the below command to check whether port:9990 is listening or not. It showed following output-

$ netstat -lp | grep 9990
tcp6       0      0 [::]:9990               [::]:*                  LISTEN      1666/docker-proxy

But on trying to connect to a remote server with hostname:port(x.x.x.x:9990) i am getting the error as -Cannot connect to x.x.x.x:9990 using service:jmx:rmi:///jndi/rmi://x.x.x.x:9990/jmxrmi.

User123
  • 147
  • 3
  • 13
  • Possible duplicate of [How to access JMX interface in docker from outside?](https://stackoverflow.com/questions/31257968/how-to-access-jmx-interface-in-docker-from-outside) – jvwilge Jun 08 '17 at 13:16
  • No its not as I have performed the changes suggested in that web page and didn't work for me. – User123 Jun 08 '17 at 13:30

1 Answers1

0

It matters how you create a container from Docker image.

If you want to expose port for connecting from outside of container then you need to pass next to your docker run command:

-p 9990:9990
webdizz
  • 828
  • 7
  • 10
  • I am unable to ping docker ip address from outside. can anyone please help me to resolve this problem. – User123 Jun 12 '17 at 06:43