You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+39-30
Original file line number
Diff line number
Diff line change
@@ -15,13 +15,14 @@ Previous 0.20.x versions are still available at https://hub.docker.com/r/nodered
15
15
## Quick Start
16
16
To run in Docker in its simplest form just run:
17
17
18
-
docker run -it -p 1880:1880 --name mynodered nodered/node-red
18
+
docker run -it -p 1880:1880 -v node_red_data:/data --name mynodered nodered/node-red
19
19
20
20
Let's dissect that command:
21
21
22
22
docker run - run this container, initially building locally if necessary
23
23
-it - attach a terminal session so we can see what is going on
24
24
-p 1880:1880 - connect local port 1880 to the exposed internal port 1880
25
+
-v node_red_data:/data - mount the host node_red_data directory to the container /data directory so any changes made to flows are persisted
25
26
--name mynodered - give this machine a friendly local name
26
27
nodered/node-red - the image to base it on - currently Node-RED v1.1.3
27
28
@@ -101,7 +102,7 @@ The minimal versions (without python and build tools) are not able to install no
101
102
102
103
For example - to run the latest minimal version, you would run
103
104
```
104
-
docker run -it -p 1880:1880 --name mynodered nodered/node-red:latest-minimal
105
+
docker run -it -p 1880:1880 -v node_red_data:/data --name mynodered nodered/node-red:latest-minimal
105
106
```
106
107
107
108
The Node-RED images are based on [official Node JS Alpine Linux](https://hub.docker.com/_/node/) images to keep them as small as possible.
@@ -186,7 +187,7 @@ Therefore all tags regarding Raspberry PI's are dropped.
186
187
187
188
For example: suppose you are running on a Raspberry PI 3B, which has `arm32v7` as architecture. Then just run the following command to pull the image (tagged by `1.1.3-10-arm32v7`), and run the container.
188
189
```
189
-
docker run -it -p 1880:1880 --name mynodered nodered/node-red:latest
190
+
docker run -it -p 1880:1880 -v node_red_data:/data --name mynodered nodered/node-red:latest
190
191
```
191
192
192
193
The same command can be used for running on an amd64 system, since docker discovers its running on a amd64 host and pulls the image with the matching tag (`1.1.3-10-amd64`).
@@ -195,7 +196,8 @@ This gives the advantage that you don't need to know/specify which architecture
195
196
196
197
**Note**: Currently there is a bug in Docker's architecture detection that fails for `arm32v6` - eg Raspberry Pi Zero or 1. For these devices you currently need to specify the full image tag, for example:
197
198
```
198
-
docker run -it -p 1880:1880 --name mynodered nodered/node-red:1.1.3-10-minimal-arm32v6
199
+
docker run -it -p 1880:1880 -v node_red_data:/data --name mynodered nodered/node-red:1.1.3-10-minimal-arm32v6
200
+
199
201
```
200
202
201
203
## Raspberry PI - native GPIO support
@@ -256,17 +258,17 @@ to store persistent or shared data outside the container.
256
258
To create a new named data volume to persist our user data and run a new
@@ -350,7 +352,7 @@ The flows configuration file is set using an environment parameter (**FLOWS**),
350
352
which defaults to *'flows.json'*. This can be changed at runtime using the
351
353
following command-line flag.
352
354
```
353
-
docker run -it -p 1880:1880 -e FLOWS=my_flows.json nodered/node-red
355
+
docker run -it -p 1880:1880 -e FLOWS=my_flows.json -v node_red_data:/data nodered/node-red
354
356
```
355
357
356
358
**Note**: If you set `-e FLOWS=""` then the flow file can be set via the *flowFile*
@@ -360,7 +362,7 @@ Node.js runtime arguments can be passed to the container using an environment
360
362
parameter (**NODE_OPTIONS**). For example, to fix the heap size used by
361
363
the Node.js garbage collector you would use the following command.
362
364
```
363
-
docker run -it -p 1880:1880 -e NODE_OPTIONS="--max_old_space_size=128" nodered/node-red
365
+
docker run -it -p 1880:1880 -e NODE_OPTIONS="--max_old_space_size=128" -v node_red_data:/data nodered/node-red
364
366
```
365
367
366
368
Other useful environment variables include
@@ -439,49 +441,55 @@ docker id number and be running on a random port... to find out run
439
441
You can now point a browser to the host machine on the tcp port reported back, so in the example
440
442
above browse to `http://{host ip}:49154`
441
443
444
+
**NOTE**: as this does not mount the `/data` volume externally any changes to flows will not be saved and if the container is redeployed or upgraded these will be lost. The volume may persist on the host filing sysem and can probably be retrieved and remounted if required.
445
+
442
446
## Linking Containers
443
447
444
-
You can link containers "internally" within the docker runtime by using the --link option.
448
+
You can link containers "internally" within the docker runtime by using Docker [user-defined bridges](https://docs.docker.com/network/bridge/).
449
+
450
+
Before using a bridge, it needs to be created. The command below will create a new bridge called **iot**
451
+
452
+
docker network create iot
445
453
446
-
For example I have a simple MQTT broker container available as
454
+
Then all containers that need to communicate need to be added to the same bridge using the **--network** command line option
447
455
448
-
docker run -it --name mybroker eclipse-mosquitto
456
+
docker run -itd --network iot --name mybroker eclipse-mosquitto
449
457
450
458
(no need to expose the port 1883 globally unless you want to... as we do magic below)
451
459
452
-
Then run nodered docker - but this time with a link parameter (name:alias)
460
+
Then run nodered docker, also added to the same bridge
453
461
454
-
docker run -it -p 1880:1880 --name mynodered --link mybroker:broker nodered/node-red
462
+
docker run -itd -p 1880:1880 --network iot --name mynodered nodered/node-red
455
463
456
-
the magic here being the `--link` that inserts a entry into the node-red instance
457
-
hosts file called *broker* that links to the external mybroker instance.... but we do
458
-
expose the 1880 port so we can use an external browser to do the node-red editing.
464
+
containers on the same user-defined bridge can take advantage of the built in name resolution provided by the bridge and use the container name (specified using the **--name** option) as the target hostname.
459
465
460
-
Then a simple flow like below should work - using the alias *broker* we just set up a second ago.
This way the internal broker is not exposed outside of the docker host - of course
465
-
you may add `-p 1883:1883` etc to the broker run command if you want to see it...
474
+
you may add `-p 1883:1883` etc to the broker run command if you want other systems outside your computer to be able to use the broker.
466
475
467
476
### Docker-Compose linking example
468
477
469
478
Another way to link containers is by using docker-compose. The following docker-compose.yml
470
-
file creates a Node-RED instance, and a local MQTT broker instance. In the Node-RED flow the broker can be addressed simply as `broker` at its default port `1883`.
479
+
file creates a Node-RED instance, and a local MQTT broker instance. In the Node-RED flow the broker can be addressed simply as `mybroker` at its default port `1883`.
471
480
472
481
```
473
482
version: "3.7"
474
483
475
484
services:
476
-
node-red:
485
+
mynodered:
477
486
image: nodered/node-red
478
487
restart: unless-stopped
479
488
volumes:
480
489
- /home/pi/.node-red:/data
481
490
ports:
482
491
- 1880:1880
483
-
484
-
broker:
492
+
mybroker:
485
493
image: eclipse-mosquitto
486
494
restart: unless-stopped
487
495
```
@@ -492,12 +500,12 @@ Sometimes it is useful to debug the code which is running inside the container.
492
500
493
501
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:
494
502
```
495
-
docker run -it -p 1880:1880 -p 9229:9229 --name mynodered --entrypoint npm nodered/node-red run debug -- --userDir /data
503
+
docker run -it -p 1880:1880 -p 9229:9229 -v node_red_data:/data --name mynodered --entrypoint npm nodered/node-red run debug -- --userDir /data
496
504
```
497
505
498
506
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:
499
507
```
500
-
docker run -it -p 1880:1880 -p 9229:9229 --name mynodered --entrypoint npm nodered/node-red run debug_brk -- --userDir /data
508
+
docker run -it -p 1880:1880 -p 9229:9229 -v node_red_data:/data --name mynodered --entrypoint npm nodered/node-red run debug_brk -- --userDir /data
501
509
```
502
510
Note that in this case NodeJs will wait - at the first statement of the Node-RED application - until a debugger client connects...
503
511
@@ -512,6 +520,7 @@ Let's dissect both commands:
512
520
-it - attach a terminal session so we can see what is going on
513
521
-p 1880:1880 - connect local port 1880 to the exposed internal port 1880
514
522
-p 9229:9229 - connect local port 9229 to the exposed internal port 9229 (for debugger communication)
523
+
-v node_red_data:/data - mount the internal /data to the host mode_red_data directory
515
524
--name mynodered - give this machine a friendly local name
516
525
--entrypoint npm - overwrite the default entrypoint (which would run the *'start'* script)
517
526
nodered/node-red - the image to base it on - currently Node-RED v1.1.0
@@ -533,7 +542,7 @@ on permissions.
533
542
If you are seeing *permission denied* errors opening files or accessing host devices, try running the container as the root user.
534
543
535
544
```
536
-
docker run -it -p 1880:1880 --name mynodered -u root nodered/node-red
If you want to modify the default timezone, use the TZ environment variable with the [relevant timezone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
563
572
564
573
```
565
-
docker run -it -p 1880:1880 --name mynodered -e TZ=Europe/London nodered/node-red
0 commit comments