Search code examples
node.jsintellij-ideadockerremote-debuggingdocker-compose

Remote debugging running process inside docker container


I'm running a node.js application inside a Docker container. I need to debug this application with Intellij Ultimate 15.

demoapp:
  build: .
  command: 'bash -c "npm install && npm run debug"'
  ports:
    - "8989:8989"
  environment:
      VIRTUAL_HOST: 'demoapp.docker'
      VIRTUAL_PORT: 8989

The debug script from package.json

"debug": "(node-inspector --web-port=8989  app.js &) && node --debug app.js"

And the configuration in the IDE

enter image description here

The IDE responds with a Frame is not available. I guess it couldn't connect.

Am I doing something wrong?

Moreover, I'm able to debug using Chrome. If I visit the demoapp.docker:8989 it connects and I can start debugging.


Solution

  • You should connect to the debug port via IntelliJ debugger, not to the web port. So you should specify it (with the --debug option) on the node runtime and expose it to the docker host and after that you'll be able to connect to it.

    More info in the JetBrains documentation: https://www.jetbrains.com/idea/help/running-and-debugging-node-js.html#remote_debugging