Debugging Java containers
Can you debug Java applications within your container? Yes.
How? Check below…
- Modify your dockerfile
- To expose JPDA params
*ENV JPDA\_OPTS="-agentlib:jdwp=transport=dt\_socket,address=8000,server=y,suspend=n"*
- To expose the debug port along with application port
EXPOSE 7080 **8000**
- To add the options in your command
CMD \["sh", "-c", "java **\$JPDA\_OPTS** -Durl=\$url -jar app.jar"\]
\- Build the docker and run with exposing the app port and debug port.</font>
docker run –d -p 7080:7080 \<docker image\>
\- Open the project in Eclipse and create a debug configuration with Host and debug port
- Set the breakpoints and Launch the debug configuration. Voila! You are debugging the application in running container.