Skip to content

Commit c99396d

Browse files
author
Dave Conway-Jones
committed
Update docker.md
1 parent 94d0ef8 commit c99396d

File tree

1 file changed

+44
-18
lines changed

1 file changed

+44
-18
lines changed

docs/getting-started/docker.md

+44-18
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ was renamed to `nodered/node-red`.
1616
Previous 0.20.x versions are still available at https://hub.docker.com/r/nodered/node-red-docker.
1717

1818
### Quick Start
19+
1920
To run in Docker in its simplest form just run:
2021

2122
docker run -it -p 1880:1880 --name mynodered nodered/node-red
@@ -116,6 +117,7 @@ This can either be done using a bind mount or a named data volume.
116117
Node-RED uses the `/data` directory inside the container to store user configuration data.
117118

118119
#### Using a Host Directory for Persistence (Bind Mount)
120+
119121
To save your Node-RED user directory inside the container to a host directory outside the container, you can use the
120122
command below. To allow access to this host directory, the node-red user (default uid=1000) inside the container must
121123
have the same uid as the owner of the host directory.
@@ -147,9 +149,15 @@ local node_red_user_data
147149
$ docker run -it -p 1880:1880 -v node_red_user_data:/data --name mynodered nodered/node-red
148150
```
149151

152+
If you need to backup the data from the mounted volume you can access it while the container is running.
153+
```
154+
$ docker cp mynodered:/data /your/backup/directory
155+
```
156+
150157
Using Node-RED to create and deploy some sample flows, we can now destroy the
151158
container and start a new instance without losing our user data.
152159
```
160+
$ docker stop mynodered
153161
$ docker rm mynodered
154162
$ docker run -it -p 1880:1880 -v node_red_user_data:/data --name mynodered nodered/node-red
155163
```
@@ -232,52 +240,62 @@ docker run -it -p 1880:1880 -e NODE_OPTIONS="--max_old_space_size=128" nodered/n
232240

233241
### Running headless
234242

235-
The barest minimum we need to just run Node-RED is
236-
237-
$ docker run -d -p 1880 --name mynodered nodered/node-red
238-
239-
This will create a local running instance of a machine - that will have some
240-
docker id number and be running on a random port... to find out run
241-
242-
$ docker ps
243-
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
244-
dd78e5bab6c4 nodered/node-red "npm start -- --user…" 7 seconds ago Up 5 seconds 0.0.0.0:32768->1880/tcp charming_chatterjee
245-
$
246-
247-
You can now point a browser to the host machine on the tcp port reported back, so in the example
248-
above browse to `http://{host ip}:32768`
243+
To run headless, (i.e. in the background), just replace the `-it` in most previous commands
244+
with `-d`, for example:
245+
```
246+
docker run -d -p 1880:1880 --name mynodered nodered/node-red
247+
```
249248

250249
### Container Shell
251250

252251
Once it is running headless you can use the following command to get access back into the container.
253252
```
254253
$ docker exec -it mynodered /bin/bash
254+
bash-4.4$
255255
```
256256

257257
Will give a command line inside the container - where you can then run the npm install
258-
command you wish - e.g.
258+
command you wish - for example
259259
```
260260
bash-4.4$ npm install node-red-dashboard
261261
bash-4.4$ exit
262262
$ docker stop mynodered
263263
$ docker start mynodered
264264
```
265265

266-
Refreshing the browser page should now reveal the newly added node in the palette.
266+
Refreshing the browser page should now reveal the newly added nodes in the palette.
267+
268+
### Multiple Instances
269+
270+
Running
271+
```
272+
docker run -d -p 1880 nodered/node-red
273+
```
274+
will create a local running instance of a machine. Note: we did not specify a name.
275+
276+
This container will have an id number and be running on a random port... to find out which port, run `docker ps`
277+
```
278+
$ docker ps
279+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
280+
860258cab092 nodered/node-red "npm start -- --user…" 10 seconds ago Up 9 seconds 0.0.0.0:32768->1880/tcp dazzling_euler
281+
```
282+
283+
You can now point a browser to the host machine on the tcp port reported back, so in the example
284+
above browse to `http://{host ip}:32768`
267285

268286
### Linking Containers
269287

270288
You can link containers "internally" within the docker runtime by using the --link option.
271289

272290
For example I have a simple MQTT broker container available as
273291

274-
docker run -it --name mybroker eclipse-mosquitto
292+
docker run -it --name mybroker eclipse-mosquitto
275293

276294
(no need to expose the port 1883 globally unless you want to... as we do magic below)
277295

278296
Then run nodered docker - but this time with a link parameter (name:alias)
279297

280-
docker run -it -p 1880:1880 --name mynodered --link mybroker:broker nodered/node-red
298+
docker run -it -p 1880:1880 --name mynodered --link mybroker:broker nodered/node-red
281299

282300
the magic here being the `--link` that inserts a entry into the node-red instance
283301
hosts file called *broker* that links to the external mybroker instance.... but we do
@@ -291,6 +309,7 @@ This way the internal broker is not exposed outside of the docker host - of cour
291309
you may add `-p 1883:1883` etc to the broker run command if you want to see it...
292310

293311
### Raspberry PI - native GPIO support
312+
294313
| v1.0 - BREAKING: Native GPIO support for Raspberry PI has been dropped |
295314
| --- |
296315
The replacement for native GPIO is [node-red-node-pi-gpiod](https://github.com/node-red/node-red-nodes/tree/master/hardware/pigpiod).
@@ -311,6 +330,13 @@ Disadvantages of the native GPIO support are:
311330

312331
**Note**: There is a contributed [gpiod project](https://github.com/corbosman/node-red-gpiod) that runs the gpiod in its own container rather than on the host if required.
313332

333+
### Serial Port - Dialout - Adding Groups
334+
335+
To access the host serial port you may need to add the container to the `dialout` group. This can be enabled by adding `--group-add dialout` to the start command. For example
336+
```
337+
docker run -it -p 1880:1880 --group-add dialout --name mynodered nodered/node-red
338+
```
339+
314340
---
315341

316342
### Common Issues and Hints

0 commit comments

Comments
 (0)