我想为我的应用使用官方node
泊坞窗图像。但是,我无法让远程调试器在主机上工作。我正在使用Visual Studio代码连接到远程调试器。使用Visual Studio远程调试Docker中的NodeJS代码
奇怪的是使用非官方的图像cusspvz/node
远程调试器工作正常。
当我运行docker log
对容器我得到以下输出的cusspvz/node
实例:
Debugger listening on [::]:5858
然而,当我运行docker log
对容器的node
例子中,我得到:
Debugger listening on 127.0.0.1:5858
这使我相信调试器正在监听错误的IP a地址(应该是通配符而不是本地主机?)
我试过内置调试器以及nodemon。不幸的是,我无法让节点检查器工作,因为它无法安装(看起来构建失败了)。
这里是我的Dockerfile:
FROM node
WORKDIR /scraper
EXPOSE 5858
ENTRYPOINT ["/bin/bash", "-c", "if [ -z \"$REMOTE_DEBUGGING\" ]; then node --debug index.js; else node --debug-brk index.js; fi"]
COPY . /scraper
RUN npm install
我开始与码头工人,撰写的容器,使用这种YML文件:
version: '2'
services:
alt.nphotos.imagescraper:
container_name: nscraper
hostname: nscraper
build:
context: ./ALT.NPhotos.ImageScraper
dockerfile: Dockerfile.debug
environment:
- REMOTE_DEBUGGING=1
- AMQP_CONNECTIONSTRING=amqp://guest:[email protected]
ports:
- "5858:5858"
任何想法? - TIA!
完整侧面说明你的问题:你应该指定一个版本号标记你的' FROM'指令。例如'FROM node:6.9.5' ...否则,每次构建图像时,都会得到最新的/最新的节点版本。这听起来不错,直到不需要的升级破坏你的代码 –
谢谢@DerickBailey我会记住这一点 –
你试过这个:http://stackoverflow.com/questions/12440169/how-do-you-debug- a-node-js-server-running-with-chrome-webkit-as-the-the-remote-debug –