Debug conluz running in a Docker container through IntelliJ IDEA - lucoenergia/conluz GitHub Wiki

  1. 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
  1. Setup a run configuration to run the application using Docker
    1. Go to Run | Edit Configurations
    2. Click the plus icon (+) and select "Docker" -> "Docker Compose"
    3. Give it a name (e.g., "Run conluz from Docker")
    4. Select the docker-compose.yml file located in the deploy folder.
    5. Select service conluz
    6. Modify the configuration to build always
    7. Add a before launch configuration to run the Gradle tasks clean build -x test
    8. Apply the changes

imagen

  1. 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:
    1. Go to Run | Edit Configurations
    2. Click the plus icon (+) and select "Remote JVM Debug"
    3. Give it a name (e.g., "Conluz Remote Debug")
    4. Keep the default port as 5005 and localhost as host.
    5. Select as module classpath conluz.main
    6. Add a before launch configuration to run the previously configured Docker run configuration
    7. Apply the changes

imagen

  1. Start your application:

    1. Start the debug session in IntelliJ IDEA by clicking the debug icon next to your Remote JVM Debug configuration.
  2. Set breakpoints in your code by clicking on the left gutter of the editor at the desired line numbers.

  3. 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.