user10888158
user10888158

Reputation:

How to load a specific flow whenever Node-red server is started through docker?

I am running Node-red server through docker-compose and it creates new flow every time the 'docker-compose up' is executed. How to prevent this from happening? And how to load/import a specific flow instead of the new one as it is hectic to copy the nodes on to the new flow every time? Thank you!

nodered_1        | 9 Jan 05:32:55 - [warn] ------------------------------------------------------
nodered_1        | 9 Jan 05:32:55 - [warn] [node-red/rpi-gpio] Info : Ignoring Raspberry Pi specific node
nodered_1        | 9 Jan 05:32:55 - [warn] ------------------------------------------------------
nodered_1        | 9 Jan 05:32:55 - [info] Settings file  : /var/node-red/settings.js
nodered_1        | 9 Jan 05:32:55 - [info] User directory : /var/node-red
nodered_1        | 9 Jan 05:32:55 - [info] Flows file     : /var/node-red/flows_dc4a44db1d02.json
nodered_1        | 9 Jan 05:32:55 - [info] Creating new flow file
nodered_1        | 9 Jan 05:32:55 - [info] Starting flows
nodered_1        | 9 Jan 05:32:55 - [info] Started flows
nodered_1        | 9 Jan 05:32:55 - [info] Server now running at http://127.0.0.1:1880/

Upvotes: 0

Views: 1491

Answers (1)

hardillb
hardillb

Reputation: 59696

You need to pass in the name of flow to use, how to do this is described in the README for the Node-RED docker image:

$ docker run -it -p 1880:1880 -e FLOWS=my_flows.json nodered/node-red-docker

You will also need to mount your own data directory so the flow is persisted across new instances being created, again this is in the README here

$ docker run -it -p 1880:1880 -v ~/.node-red:/data --name mynodered nodered/node-red-docker

so combining the 2 will get you:

$ docker run -it -p 1880:1880 -e FLOWS=my_flow.json -v ~/.node-red:/data --name mynodered nodered/node-red-docker

You will have to take that command line and map it into the docker-compose file.

Upvotes: 1

Related Questions