Open vielmetti opened 8 years ago
It's a good idea. I'm tired of reinstalling my flow with each setup.
I also discovered that it's possible to very straightforwardly extend this image to add some more Node-RED nodes, with a Dockerfile that looks something like this. It's not the only way to take on this task, but it might be useful:
# Dockerfile for node-red-wx
# Start from the version we'll be working against to save space
FROM nieleyde/rpi2-nodered
# Install some bloat (er, nodes)
RUN ( mkdir .node-red && \
cd .node-red && \
npm install -g node-red-node-weather-underground \
node-red-node-openweathermap \
node-red-node-forecastio )
Build that Dockerfile, when the build happens it will pull in a few more nodes into the npm global space (-g). This made those nodes visible from the new instance but did not require rebuilding the whole thing from scratch.
OK more notes to share - this on using docker compose
to connect two containers together, namely a Node-RED container and a mosquitto container.
This file is docker-compose.yml
and it brings up both services. There is still more refinement to do, seeing as I really want to run the mosquitto container with a non-default config file so that I can have its persistence layer in a file on the host machine. But here's something.
nodered:
image: nieleyde/rpi2-nodered
command: flows.json
volumes:
- /home/pi/node-red:/root/.node-red
ports:
- "1880:1880"
links:
- mosquitto
mosquitto:
image: nieleyde/rpi-mosquitto
ports:
- "1883:1883"
Just a note that the main "Node-RED on Docker" Github epic issue is at
So I'm sorting how to take this image (rpi2-nodered) and extend it with a customized configuration - a separate settings file, a separate flows file, and some set of additional nodes. I think it can all be done within Docker without changing the core image.
The simplest thing I figured out was how to persist the flows file between runs. To do this simply create a directory on the system and then mount it as a volume, like so
Node-RED will pick up additional nodes from that home directory, so at least in theory you should be able to create a data volume container with a set of added nodes as well and then mount it appropriately.
I'll find an appropriate issue in the main node-red discussion of running under Docker to complete this thought, but just thought I'd share a success here.