Skip to content
Advertisement

How to debug a JDK docker container in intellij idea?

I want to start up a docker container with debug options as follows, but the startup won’t work:

Dockerfile:

JavaScript

docker-compose.yml:

JavaScript

Result:

JavaScript

Sidenote: Port 5005 is of course not running/listening on my host! Also, if I change the port to 5006, 5007 etc, the error is always the same.

So why is the port blocked on mvn spring-boot:run?

Advertisement

Answer

The problem with your solution is that there are 2 debug sessions being started. 1 for the maven command and 1 for the forked JVM voor Spring Boot. Hence the error and changing the port won’t solve this as the problem will remain.

What you need to do is remove the JAVA_TOOL_OPTIONS from your docker compose file and instead add the following to your entry point

JavaScript

That way it will only apply to the Spring Boot plugin and will be taken into account when launching the app in a new JVM.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement