Is there a way to remote debug a test case or application that must be executed within an already running docker container?


I have a docker compose setup that starts multiple containers:

  • a running database
  • a container that contains the the runtime and build environment for the java application that is developed with IntelliJ

The java application is not startet, the build system is Gradle. The application can be build and tested running gradlew (the Gradle wrapper) within that running container (it has certain settings which respect to users, permissions and python path).

IntelliJ is running on the machine where Docker (for Mac) is then running the docker compose setup. The source code is mounted into the docker container such that the same files are available for IntelliJ and the Gradle build within the container.

Currently if I just want to debug a single test case I need to create a Gradle task, define the agent lib properties to wait for a remote debugger, then execute this task within the container, switch back to IntelliJ and start a remote debugging session.

This is much more complicated than just click on the debug arrow of the single test case within the source code editor. Is there any way to make this more convenient?

评论操作 固定链接

Hi Olav,

Let me look into this and get back to you.

评论操作 固定链接

Olav Rabe

Single-click-to-debug should be possible if you use a Docker Compose run target in your usual Application or Gradle run/debug configuration.

We do not have a step-by-step guide for the process in our documentation yet, so feel free to leave additional comments in this thread if you run into any problems.

评论操作 固定链接

That's not really working as needed. I guess what I'm looking for is something that is discussed here:

And by the way: We have a working solution with VS Code in place. But I won't drop the better refactoring capabilities that IntelliJ provides by switching to VS Code.