Raspberry Pi

Node-RED on Docker

We already played with Node-RED and Node-RED Dashboard earlier. Those recipes, which allow you to install those essential components on your Raspberry Pi work fine, yet we see more and more installation questions coming. Time to upgrade!

This is a very easy recipe to install Node-RED and Node-RED Dashboard the easy way, using Docker. Inspiration comes from the official home site, but we have a few extras (and our own Node-RED version) in store. Read on to learn more.

We present 2 options.

Option1 - Simple Node-RED Setup

This option is based on this article: Running Node-RED Under Docker (official guide). We just added a few extras for Raspberry Valley use. It is highly recommended to check out this original.

Within a few minutes, you'll get a fully operational Node-RED server running on your Pi!

  • Setup a base Raspberry Pi OS: You can easily get started on any recent image of Raspbian (or other Raspberry Pi system, such as Ubuntu Mate), or use any of our previous recipes: for example Raspberry Pi Headless Setup
  • Setup Docker: Follow our simple tutorial here: Docker on Raspberry Pi
  • Open up the Terminal. We'll do all the work from there
  • Pull the Node-RED official image: please note we use the ARM version, in our case tagged with rpi
docker pull nodered/node-red-docker:rpi

Wait a bit. You'll see something similar to this:

pulling nodered official image

  • Test the image. The below test will allow you to start a Docker container with Node-RED, test the server and see any possible error messages in the console. Notice that the container is destroyed again after use.
docker run -it --rm -p 1880:1880 nodered/node-red-docker:rpi

Your server is functional and is accessible via the browser at

http://your-pi-ip-or-hostname:1880

and looks similar to this on server (Raspberry Pi):

test nodered official image

and in Browser:

test nodered official image in browser

To exit, press ctrl-c on your Pi. The test container will be removed and your changes on test will be lost.

  • Time to setup your container for good. There are several options here; you can run in container only, map a directory to your flows to persist them during update, running on different ports etc. Please investigate the documentation a bit. For Raspberry Valley users, we assume the most simple possible approach. You might need a bit more ...

This command creates a container noderedrv on your Pi:

docker run -d -p 1880:1880 --name noderedrv nodered/node-red-docker:rpi

Note, that you need to re-start the container after reboot (or change options), that you need to make sure you properly backup your Nodes etc.

Below are a few useful Docker commands to work with this container:

# To stop the container
docker stop noderedrv

# To start the container
docker start noderedrv
  • Time to setup Node-RED Dashboard: Open up your browser and navigate to
http://your-pi-ip-or-hostname:1880

Locate the menu button (right top) -> Select 'Manage Palette' -> Select the 'Install' tab -> search for 'node-red-dashboard' -> Click Install

installing nodered dashboard

Note: You can install other nodes in a similar way

  • Done. Your system is available and ready to use

Option 2 - Our own Node-RED Docker Image

We have created our own Node-RED image, based on the official image. The difference is, that our favourite nodes are added. Please find the Docker image to use here on Docker Hub, The source code on Github and the changelog on the Github repository in README-RaspberryValley.md

  • Simply pull our image
docker pull raspberryvalley/nodered:rpi
  • Create the container
docker run -d -p 1880:1880 --name noderedrv raspberryvalley/nodered:rpi
  • and - DONE!

Tips

Here is a bunch of tips to take you from our base configuration further.

Autostart the Node-RED Container

You can modify the container behavior by using the update command. This applies to any Docker container. However after finishing the steps above, you need to manually start the container. So let's automate this.

To set autostart properties, use this command:

docker update --restart {no,on-failure,unless-stopped,always} container_name

In our case, this boils down to:

docker update --restart always noderedrv