Remote Debugging with JPDA won't connect to Tomcat through eclipse when using Docker-Compose

Viewed 4483

I'm very new to Docker so this could be something simple I'm doing wrong. With all the solutions out there I've been able to get remote debugging working with eclipse when using 'Docker run' to launch the Tomcat container.

docker run -it --rm -e JPDA_ADDRESS=8000 -e JPDA_TRANSPORT=dt_socket -p 8888:8080 -p 8000:8000 tomcat:8.0-jre8 /usr/local/tomcat/bin/catalina.sh jpda run

However when using docker-compose, I get a "Failed to connect to remote VM. Connection refused" dialog.

docker-compose up

docker-compose.yml settings:

tomcat: image: tomcat:8.0-jre8 # START - REMOTE DEBUGGING SETTINGS # Didn't work with or without this network_mode setting. But the bridge settings as seen with 'docker container inspect *CID*' looks almost identical to the working solution network_mode: bridge environment: - JPDA_ADDRESS:8000 - JPDA_TRANSPORT:dt_socket entrypoint: /usr/local/tomcat/bin/catalina.sh jpda run # END - REMOTE DEBUGGING SETTINGS deploy: restart_policy: condition: on-failure placement: constraints: [node.role == manager] ports: - 8888:8080 # REMOTE DEBUGGING SETTINGS jpda port - 8000:8000

My eclipse settings that work with 'docker run' are:

Remote Java Application: Host: localhost Port: 8000

Note: With the docker-compose settings I also see the expected print in the startup output:

Listening for transport dt_socket at address: 8000

and also with both deployments I can access the web service's functionality through the exposed port 8888. ie. This simple link returns 'Hello'.

http://localhost:8888/MyEmulatorService/rest/MES/

Any thoughts on why I can't remote debug when launching this way? I suspect there's a subtle difference in the way the network configuration is setup.

2 Answers

Usually we are using

 environment:
 - JAVA_OPTS= -agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
Related