How to remote debug tomcat docker container

This is very simple task. I will use IntelliJ idea as my IDE. If you are reading this article you should work with docker and you might familiar with that. Because of that i won’t explain the part of creating a docker container.

First thing you need to do it to add following environment variables.

-e JPDA_ADDRESS=8000 \
-e JPDA_TRANSPORT=dt_socket \

Then you need to run tomcat container with jpda parameter. So full docker run script can be like below

docker run -it --rm \
-e JPDA_ADDRESS=8001 \
-e JPDA_TRANSPORT=dt_socket \
-p 8080:8080 \
-p 8001:8001 \
tomcat:8.0 \
/usr/local/tomcat/bin/ jpda run

Now your tomcat container is started in debug mode. Now you need to open the application in IntelliJ which is running on the container and set a debug point to somewhere.

Open the run/debug configuration window. Then click + and select remote. Now add the host and JPDA port and click apply. Finally click the debug icon then you will be able to debug you application.

Sometimes you will get this error.

Debug: Unable to open debugger port ( “Connection refused”

This happens because your jpda port is not exposed to outside of the container or else you didn’t run docker container with jpda run.

Hope you enjoyed today lesson. Thank you for reading this. Don’t forget to put a comment if you have any issue

If you like this post, you can read more articles on my personal blog



Software Engineer at Creative Software

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store