1

I am trying to attach a remote debugger to a node.js app running in docker from within WebStorm but am unable to do. I can successfully run docker app from IDE but cannot debug it.

I am following this guide to setup remote interpreter : https://www.jetbrains.com/help/webstorm/running-and-debugging-node-js.html#node_debugging_overview

My docker-compose.yaml looks something like this:

ports:
  - 8080:8080
  - 9229:9229

command: [ "npm", "run","debug" ]

package.json has debug script defined like :

"debug":"node --inspect-brk"

If someone has set this up can you please suggest what am I not doing correct ?

2 Answers 2

2

You need to bind to all interfaces in container

--inspect=0.0.0.0

or

--inspect-brk=0.0.0.0

Command-line options

However this is dangerous in production environments Exposing the debug port publicly is unsafe

Sign up to request clarification or add additional context in comments.

1 Comment

Thank You for all your replies : So this is what my debug script looks like now: "develop": "NODE_ENV=development node -- --inspect=0.0.0.0:8090 ./baseFille.js" Another weird thing is when i send a curl Request to port 8090 (which is suppose to be my debugger port) i don't get any response. Can that be the issue why i cannot debug?
1

Using Docker Compose as Node.js remote interpreter is not currently supported, see WEB-23404. So you need using Attach to Node.js/Chrome run configuration to attach to your node.js app running in docker:

enter image description here

But, as node binds to localhost by default and thus can't be accessed from outside, you need changing your npm script to "debug":"node --inspect-brk=0.0.0.0:9229", as it's mentioned in @ponury-kostek answer

2 Comments

So i tried using this but for some reason it breaks up abruptly and comes out. Gives a error message with 'driver failed programming external connectivity on endpoint'.
doesn't look related to debugging. see github.com/docker/compose/issues/3277 for some hints

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.