I'm trying to connect eclipse to a docker container I have running but I am having trouble.
My docker run command is as follows:
docker run --rm -it -p 8000:8000 -p=8668:8080 -p 8010:8009 -p 8443:8443 \
--name myContainer -h theContainer -e JVM_ROUTE=myContainer1 myContainer:qa
In eclipse, I'm connecting with localhost
as the host, and 8000
as the port. I go to Run->Debug Configurations->Remote Java Application, and I've created a new debug configuration.
When I click apply, then debug, I get a pop up error message Failed to connect to remote VM.
What else do I need to do to get remote debugging working properly?
To attach to a running process in a Windows Docker container: In Visual Studio, select Debug > Attach to Process (or CTRL+ALT+P) to open the Attach to Process dialog box. Set the Connection type to Docker (Windows Container). Select Find... to set the Connection target using the Select Docker Container dialog box.
Eclipse Che is a next-generation cloud IDE and workspace server that can run anywhere Docker runs.
A java application running in a docker container can be remotely debugged by
Enabling JDWP for the java process in the container, e.g.
java -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y [...]
or using the JAVA_OPTS environment variable
JAVA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y"
Note that suspend=y
will prevent the application from starting until a remote debugger is attached to the JVM. If suspend=n
is used, the application will start as normal allowing a remote debugger to connect at a later time.
Connecting to the process, e.g. through your IDE, using the port specified in the address=<port>
settings above, and importantly the ip address of the docker host which, unless you are running on linux, is probably not localhost
. If you are using docker-machine
, the docker host ip can be displayed using docker-machine ip
, e.g.
$ docker-machine ip
192.168.99.100
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With