|
6 | 6 | [](https://hub.docker.com/r/nodered/node-red/) |
7 | 7 |
|
8 | 8 | This project describes some of the many ways Node-RED can be run under Docker and has support for multiple architectures (amd64, arm32v6, arm32v7, arm64v8, i386 and s390x). |
9 | | -Some basic familiarity with Docker and the [Docker Command Line](https://docs.docker.com/engine/reference/commandline/cli/) is assumed. |
| 9 | +Some basic familiarity with Docker and the [Docker Command Line](https://docs.docker.com/engine/reference/commandline/cli/) is assumed. |
10 | 10 |
|
11 | | -As of Node-RED 1.0 this project provides the build for the `nodered/node-red` container on [Docker Hub](https://hub.docker.com/r/nodered/node-red/). Note: the Docker Hub name has changed to `nodered/node-red`. |
| 11 | +As of Node-RED 1.0 this project provides the build for the `nodered/node-red` container on [Docker Hub](https://hub.docker.com/r/nodered/node-red/). |
12 | 12 |
|
13 | 13 | Previous 0.20.x versions are still available at https://hub.docker.com/r/nodered/node-red-docker. |
14 | 14 |
|
@@ -474,6 +474,38 @@ services: |
474 | 474 | restart: unless-stopped |
475 | 475 | ``` |
476 | 476 |
|
| 477 | +## Debugging containers |
| 478 | + |
| 479 | +Sometimes it is useful to debug the code which is running inside the container. Two scripts (*'debug'* and *'debug_brk'* in the package.json file) are available to start NodeJs in debug mode, which means that NodeJs will start listening (to port 9229) for a debug client. Various remote debugger tools (like Visual Code, Chrome Developer Tools ...) can be used to debug a Node-RED application. A [wiki](https://github.com/node-red/node-red-docker/wiki/Debug-container-via-Chrome-Developer-Tools) page has been provided, to explain step-by-step how to use the Chrome Developer Tools debugger. |
| 480 | + |
| 481 | +1. In most cases the *'debug'* script will be sufficient, to debug a Node-RED application that is fully up-and-running (i.e. when the application startup code is not relevant). The NodeJs server can be started in debug mode using following command: |
| 482 | + ``` |
| 483 | + docker run -it -p 1880:1880 -p 9229:9229 --name mynodered --entrypoint npm nodered/node-red run debug -- --userDir /data |
| 484 | + ``` |
| 485 | + |
| 486 | +2. In case debugging of the Node-RED startup code is required, the *'debug_brk'* script will instruct NodeJs to break at the first statement of the Node-RED application. The NodeJs server can be started in debug mode using following command: |
| 487 | + ``` |
| 488 | + docker run -it -p 1880:1880 -p 9229:9229 --name mynodered --entrypoint npm nodered/node-red run debug_brk -- --userDir /data |
| 489 | + ``` |
| 490 | + Note that in this case NodeJs will wait - at the first statement of the Node-RED application - until a debugger client connects... |
| 491 | + |
| 492 | +As soon as NodeJs is listening to the debug port, this will be shown in the startup log: |
| 493 | +``` |
| 494 | +Debugger listening on ws://0.0.0.0:9229/... |
| 495 | +``` |
| 496 | + |
| 497 | +Let's dissect both commands: |
| 498 | + |
| 499 | + docker run - run this container, initially building locally if necessary |
| 500 | + -it - attach a terminal session so we can see what is going on |
| 501 | + -p 1880:1880 - connect local port 1880 to the exposed internal port 1880 |
| 502 | + -p 9229:9229 - connect local port 9229 to the exposed internal port 9229 (for debugger communication) |
| 503 | + --name mynodered - give this machine a friendly local name |
| 504 | + --entrypoint npm - overwrite the default entrypoint (which would run the *'start'* script) |
| 505 | + nodered/node-red - the image to base it on - currently Node-RED v1.0.3 |
| 506 | + run debug(_brk) - (npm) arguments for the custom endpoint (which must be added AFTER the image name!) |
| 507 | + -- - the arguments that will follow are not npm arguments, but need to be passed to the script |
| 508 | + --userDir /data - instruct the script where the Node-RED data needs to be stored |
477 | 509 |
|
478 | 510 | ## Common Issues and Hints |
479 | 511 |
|
|
0 commit comments