IntelliJ IDEA plugin that automates port configuration of Remote JVM Debug launch configuration so that you can debug a docker container without having to know the randomly what public port has been randomly selected by docker.
- Right-click on the toolbar near the "Run" and "Debug" toolbar buttons. In the popup menu, click on "Customize Toolbar" menu item.
- In "Customize Navigation Bar Toolbar" dialog box, click on "Add Action" button.
- Search for "docker debug", and then select both "Docker Debug" and "Docker Debug Config", and then click on Ok button.
- Launch a docker container with java debugger enabled.
- This can be done with an environment variable on the container. For example,
JAVA_TOOL_OPTIONS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005
- This can be done with an environment variable on the container. For example,
- Put a breakpoint on your java project
- Create a new Remote JVM Debug run configuration
- Click on Docker Debug Config button the toolbar. On the popup dialog box, configure the following:
- Name of the Remote JVM Debug configuration that you created earlier.
- Internal port of the debugger, usually 5005.
- Name of the currently running container
- Click on Debug button the dialog box to start debugging, or click on Save button to debug later with Docker Debug button on the toolbar.
Please refer to the demo project in the demo subdirectory for a Java project that's ready for debugging.
- Remote JVM Debug
- The debug configuration that will be launched when docker debugger starts.
- Internal Port
- Port number within the container that the Java process will listen for debugger.
- Docker Container
- Docker container to attach a debugger to.
- (waitForContainerSeconds)
- Number of seconds to wait if container isn't running or the port isn't ready.
- This configuration is not visible on UI. It can be modified by adding an <option> element to workspace.xml under <component name="DockerDebug">
- For example, the snippet below would set maximum wait time to 10 seconds.
<component name="DockerDebug"> <option name="waitForContainerSeconds" value="10" /> </component>