How attach Webstorm debugger to an already running node process on a docker container

Hi,

I have a multi-container application defined in a docker-compose file. One of this containers runs a node express application using the following command:

nodemon --inspect=5858 index.js


This container expose the ports 4500 for the server and 5858 for the node debugger.

I would like to attach the Webstorm debugger to this node process on the container, specifically on the port 5858. I've tried creating a remote node interpreter configuration specifying docker-compose and the related node service:

 

But when I run the debugger Webstorm tries to recreate the service, failing because it is already running. I would like just the debugger to attach to the running process. Is this possible? 

 

0
5 comments
Avatar
Permanently deleted user

Thank you!

One thing to add is that remote debugger will not be able to attach unless the inspect option has the following format:

node --inspect=0.0.0.0:PORT file.js

Without the 0.0.0.0 host part I was not able to attach.

 

 

0

Yes, 0.0.0.0 is required as node binds to localhost by default and thus can't be accessed from outside

0
Avatar
Permanently deleted user

I have a very similar setup.

I have a multi-container application running in Docker and I am trying to attach a debugger. I am running

node --inspect=0.0.0.0:PORT path/to/angular/node/module ng serve --argshere

but I can't seem to attach to the debugger. I have an Attach to NodeJS/Chrome configuration that's bound to the inspection port and the file structure in the container is the same as that in the root project.

0

@Becky S    What are you trying to debug - ng serve command, or your Angular application? In the latter case, you should have used the JavaScript Debug run configuration to attach the debugger to your page. See https://www.jetbrains.com/help/webstorm/2020.3/angular.html#angular_running_and_debugging

0

Please sign in to leave a comment.