Docker Community Forums

Share and learn in the Docker community.

Debug Docker Desktop container using eclipse in WIndows 10

Hi I am running Docker Desktop and run an image in the container. I want to be able to debug the java app that is running in the container using eclipse remote debugging using port 8000. Below is my command to run the container and enable debugging:

docker container run -p 8080:8080 -v “volume:/data/” -d --name “image name” -e -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,server=y,suspend=y nexus:19999/image from nexus

Had to modify this going from Linux to Windows 10. I am able to debug in a Linux env. Needed to run docker on windows for multi environments.

When I try to remote debug inside eclipse using localhost as the host and port 8000 as the debug port I can’t seem to connect to the port, I get a connection refused. I tried using the VEthernet(WSL) IP address but that didn’t seem to work either.

Is there an option I am missing to expose all ports within the docker container that will allow me to hit the debug port.

Thanks

Same situation here, hard to know why, but it seems to be something with WSL2

I don’t do Java programming recently but I helped one of my colleagues to containerize a Java application. In that case the Java app was listening only on localhost and allowed connection only from localhost. We tried to change “address=PORT” (or similar parameter) to address=0:0:0:0:PORT and that solved the problem. The other solution was to use host network but in case of Docker Desktop that is not an option.

Keep in mind, even if you send a request to localhost to a forwarded port, the request goes through the Docker gateway so the container will not see you coming from localhost.

observations:
– you try to pass the JAVA_OPTS with the -e argument, without actualy following the KEY=VALUE schema it requires.
– there is no port published for the debugging port

Probably your command should look more like this:

docker container run -p 8080:8080 -p 8000:8000 -v "volume:/data/" -d --name "image name" -e "JAVA_OPTS=-Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,server=y,suspend=y" repo:tag

The JAVA_OPTS key is just a lucky guess, as it usualy works for most java based images. If it’s not working, please check your entrypoint script and see what variables are actualy expected/supported.

1 Like

Wow, I can’t believe I didn’t notice those mistakes in the question :slight_smile: So it is not so mysterious after all.