I am new to docker. I would like to attach debugger to the tests running with gradle
inside docker container and debug the tests inside IntelliJ. The docker container is running on my MacBook.
Here's the command for starting a docker container -
docker run \
--name "my_test_container" \
-v $(pwd):/root/workspace \
-e BRANCH_NAME="${BRANCH_NAME}" \
-p 127.0.0.1:4455:4455/tcp \
-it "${DOCKER_IMAGE}"
The command to run the tests is -
gradle clean build test --info --stacktrace
I have tried --debug-jvm
option in gradle
command.
I have also included following debugOptions
in build.gradle
(excluded --debug-jvm).
test {
// few other options go here
debugOptions {
enabled = true
host = '127.0.0.1'
port = 4455
server = true
suspend = true
}
}
The execution suspends in the docker container and shows the message in docker terminal
Listening for transport dt_socket at address: 4455
When I start the debug configuration in IntelliJ, I am getting below error in IntelliJ -
IntelliJ debug configuration are as below
Do I need to perform any additional steps such as port forwarding? I am not familiar with networking concepts and wanted to get few pointers from the forum.
References
- https://github.com/gradle/gradle/issues/7496
- https://medium.com/swlh/remote-debugging-a-java-application-running-in-docker-container-with-intellij-idea-efe54cd77f02
- https://www.baeldung.com/docker-debug-app-with-intellij
- https://www.neelsomani.com/blog/ssh-tunnel-to-a-docker-container-on-a-remote-server.php
- Unable to open debugger port through IntelliJ