Search code examples
javadockerboot2dockerdocker-composedocker-machine

Cannot connect to exposed Docker port


I'm running Docker on OS X using the latest Docker Toolbox.

Docker version 1.10.2, build c3959b1
docker-machine version 0.6.0, build e27fb87
docker-compose version 1.6.0, build d99cad6

I have a Java app in a container built from the following Dockerfile:

FROM <my internal registry>/java:8

ENTRYPOINT ["java", "-cp", "/var/app/scheduler/scheduler-jar-with-dependencies.jar", "com.myapp.scheduler.Application"]

and docker-compose.yml:

scheduler:
  image: <my internal registry>/scheduler
  command: -Dspring.profiles.active=local -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5050
  environment:
    TERM: xterm
  ports:
    - "4567:4567" # http port
    - "5050:5050" # java debug port
  volumes:
    - $SCHEDULER_GIT_ROOT/target:/var/app/scheduler
    - $LOG/scheduler:/var/log/scheduler

When I bring up the container, I can hit the http port from the browser using the VMs IP (192.168.99.100:4567). I can't connect my debugger to the debug port, however, nor can I access that port at all through telnet, no matter what I change the port to. docker ps yields:

CONTAINER ID        IMAGE                                             COMMAND                  CREATED             STATUS              PORTS                                            NAMES
9395e0f20dd5        <my registry>/scheduler          "java -cp /var/app/sc"   7 minutes ago       Up 7 minutes        0.0.0.0:4567->4567/tcp, 0.0.0.0:5050->5050/tcp   scheduler_scheduler_1

Anyone know why I can connect to the one port, but not the other?

EDIT: Here's the command from docker inspect:

"Path": "java",
"Args": [
    "-cp",
    "/var/app/scheduler/scheduler-jar-with-dependencies.jar",
    "com.mlbam.cms.scheduler.Application",
    "-Dspring.profiles.active=local",
    "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5050"
] 

Solution

  • This wound up having nothing to do with Docker, but rather with the way I was running the java command. The debug args have to come before the -cp:

    java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5050 -cp /var/app/scheduler/scheduler-jar-with-dependencies.jar com.myapp.scheduler.Application