I'd like to use the official node
docker image for my app. However I cannot get the remote debugger to work on the host machine. I am using Visual Studio Code to connect to the remote debugger.
The strange thing is using an unofficial image cusspvz/node
the remote debugger works correctly.
When I run docker log
against the cusspvz/node
instance of the container I get the following output:
Debugger listening on [::]:5858
However when I run docker log
against the node
instance of the container I get:
Debugger listening on 127.0.0.1:5858
Which leads me to believe that the debugger is listening on the wrong IP address (should be wildcard rather than localhost?)
I've tried the built in debugger as well as the nodemon. Unfortunately I couldn't get node-inspector to work as it fails to install (appears that the build is failing anyway).
Here is my 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
I'm starting the container with docker-compose, using this YML file:
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:guest@nqueue
ports:
- "5858:5858"
Any ideas? - TIA!
By default node.js (and v8 behind it) always use 127.0.0.1 for the debugger. I've looked at cusspvz/node
and I can't find anywhere how it exposes the debugger like that.
It used to be difficult to change this configuration but now you can just use the debug option with an explicit host:
node --debug=[::]:5858 test.js
Debugger listening on [::]:5858
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With