Debug conluz running in a Docker container through IntelliJ IDEA - lucoenergia/conluz GitHub Wiki
- First, we'll need to modify the service "conluz" in the
docker-compose.yml
to expose a debug port and set the Java debug options.
conluz:
# ... existing configuration ...
ports:
- "8443:8443"
- "5005:5005" # Add debug port
environment:
# ... existing environment variables ...
- JAVA_TOOL_OPTIONS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005
- Setup a run configuration to run the application using Docker
- Go to
Run | Edit Configurations
- Click the plus icon (
+
) and select "Docker" -> "Docker Compose" - Give it a name (e.g., "Run conluz from Docker")
- Select the
docker-compose.yml
file located in thedeploy
folder. - Select service
conluz
- Modify the configuration to build always
- Add a before launch configuration to run the Gradle tasks
clean build -x test
- Apply the changes
- Go to
- Set up the debug configuration in IntelliJ IDEA https://www.jetbrains.com/help/idea/2025.1/run-and-debug-a-spring-boot-application-using-docker-compose.html#debug_app:
- Go to
Run | Edit Configurations
- Click the plus icon (
+
) and select "Remote JVM Debug" - Give it a name (e.g., "Conluz Remote Debug")
- Keep the default port as
5005
andlocalhost
as host. - Select as module classpath
conluz.main
- Add a before launch configuration to run the previously configured Docker run configuration
- Apply the changes
- Go to
-
Start your application:
- Start the debug session in IntelliJ IDEA by clicking the debug icon next to your Remote JVM Debug configuration.
-
Set breakpoints in your code by clicking on the left gutter of the editor at the desired line numbers.
-
When you make requests to your application, IntelliJ IDEA will pause execution at your breakpoints, allowing you to:
- Examine variable values
- Step through code
- Evaluate expressions
- View the call stack
The debugger will connect to your application running in the Docker container, and you'll have full debugging capabilities https://www.jetbrains.com/help/idea/2025.1/docker-tutorial-tomcat-debug.html#-40old5_46.