docker 容器内的远程调试 运行 进程

Remote debugging running process inside docker container

我是 运行 node.js 应用程序,位于 Docker 容器中。我需要使用 Intellij Ultimate 15.

调试此应用程序
demoapp:
  build: .
  command: 'bash -c "npm install && npm run debug"'
  ports:
    - "8989:8989"
  environment:
      VIRTUAL_HOST: 'demoapp.docker'
      VIRTUAL_PORT: 8989

来自 package.json

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

和IDE中的配置

IDE 以 Frame is not available 响应。估计连不上

我是不是做错了什么?

此外,我可以使用 Chrome 进行调试。如果我访问 demoapp.docker:8989 它会连接,我可以开始调试。

您应该通过 IntelliJ 调试器连接到调试端口,而不是 Web 端口。所以你应该在节点运行时指定它(使用 --debug 选项)并将它暴露给 docker 主机,然后你就可以连接到它了。

JetBrains 文档中的更多信息:https://www.jetbrains.com/idea/help/running-and-debugging-node-js.html#remote_debugging