I have a Java application (.tar) mounted to a container. The entrypoint of the container starts that application.
Dockerfile (the backend folder is mounted into the image as a volume)
FROM openjdk:11.0.7
ENTRYPOINT /backend/entrypoint.sh
entrypoint.sh
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -Xmx2048M -jar backend.jar
Now I want to debug that running application using VSCode's debugger. According to the official VSCode documentation (blog: inspecting containers) this can easily be done with the command palette and the command Debugger: attach to Node.js process.
But in their example they use a Node.js server. In my container however, there is no Node.js process that I could attach the debugger to and I can't find an appropriate command for a Java Spring application. So how can I attach the Java debugger of VSCode to an Java application which is already running inside a Docker container?
At another place in their documentation (containers: debug common) they state the following:
The Docker extension currently supports debugging Node.js, Python, and .NET Core applications within Docker containers.
So no mention of Java there but then again at another place (remote: debugging in a container) they clearly talk about a Java application:
For example, adding this to .devcontainer/devcontainer.json will set the Java home path: "settings": { "java.home": "/docker-java-home" }