Why Chrome can't inspect nodejs code in Docker container?

落花浮王杯 提交于 2019-12-05 08:24:02

in your package.json scripts:

"debug": "nodemon --inspect=0.0.0.0:9229 index.js",

in your docker-compose.yaml:

services: service_name: command: npm run debug ports: - 9229:9229

I am not 100% sure on this but I think that mapping the debugger to run on 0.0.0.0 exposes it to your local network meaning that anyone can connect to your machine IP on port 9229 will be able to debug your nodejs server. Beware your nodejs server has access to the filesystem. So do not run production (or development) servers with this ever.

You need "node --inspect 0.0.0.0:8000" in container. Container port 8000 is mapped to host port 9229. So you must use localhost:9229 to connect chrome-dev-tools to node-debugger in container.

Details s. https://nodejs.org/en/docs/guides/debugging-getting-started/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!