简体   繁体   English

泊坞窗中的节点检查器不会加载源

[英]Node-inspector in docker does not load sources

I've two docker containers with different images. 我有两个具有不同图像的Docker容器。 This is the partial output of "docker ps" command: 这是“ docker ps”命令的部分输出:

$user: docker ps
CONTAINER ID    IMAGE          PORTS
9c8ff81215d4    node:slim      0.0.0.0:5858->5858/tcp, 0.0.0.0:10101->10101/tcp
d85a0de91432    node-debug     0.0.0.0:8080->8080/tcp

The first container is running a server app with debug option: 第一个容器正在运行带有调试选项的服务器应用程序:

$user: node --debug server.js
Debugger listening on port 5858
...

and listens on port 5858 with debugger and on port 10101 with server.js app. 并使用调试器监听端口5858和使用server.js应用监听端口10101。

The second container is running node-inspector 第二个容器正在运行节点检查器

$user: node-inspector
Node Inspector v0.12.6
Visit http://127.0.0.1:8080/?port=5858

that connects by default on port 5858 to debugger and listens on port 8080 for web-inspector in Chrome. 默认情况下在端口5858上连接到调试器,并在端口8080上侦听Chrome中的Web检查器。

The issue is when I visit http://127.0.0.1:8080/?port=5858 I see the inspector without loaded sources. 问题是当我访问http://127.0.0.1:8080/?port=5858时,我看到检查器没有加载源。

In the Chrome console is see this error: 在Chrome控制台中看到此错误:

Request with id = 10 failed. "ErrorNotConnected: Error: connect ECONNREFUSED 127.0.0.1:5858. Is node running with --debug port 5858?"

在此输入图像描述

The problem here is that node inspector is trying to connect to localhost/127.0.0.1, ie local to that container , not local to your host. 这里的问题是节点检查器正在尝试连接到localhost / 127.0.0.1,即该容器本地,而不是主机本地。 When you run in bridge networking (default), each container is on its own IP. 在网桥网络中运行时(默认),每个容器都位于其自己的IP上。

You could quickly resolve this with either of these options: 您可以使用以下任一选项快速解决此问题:

  1. Use host networking for both containers 对两个容器使用主机网络
    • In this case the port forwarding you configured is not necessary any longer 在这种情况下,不再需要配置您的端口转发
  2. Use host networking just for the node inspector container 仅将主机联网用于节点检查器容器
    • In this case you still need port 5858 mapped to host but no longer the port 8080 on node inspector 在这种情况下,您仍然需要将端口5858映射到主机,但不再需要节点检查器上的端口8080

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM