Debugging a Java container is the same as debugging a remote Java application. All you need to do is
to add some arguments to the JVM, run the Java application and attach the debugger.
IDE
With your favorite IDE, create a new remote configuration:
Copy the command line arguments.
Docker container
We will use the following Docker image as an example:
1
2
3
4
5
6
FROM openjdk:11.0.6-jre-slimEXPOSE 8180WORKDIR /optCOPY target/heart-beat-producer.jar /optENTRYPOINT["java","-jar","/opt/heart-beat-producer.jar"]
If we want to add the debug argument, we can override the entrypoint: