Installing Node-RED using Docker on a Raspberry Pi 5
Installing Node-RED using Docker on a Raspberry Pi 5 with a 64-bit ARM architecture is a straightforward process.
This guide will walk you through the steps to get Node-RED up and running in a Docker container on your Raspberry Pi.
Prerequisites
Raspberry Pi 5 with a 64-bit ARM architecture
Raspberry Pi OS (64-bit) installed on your Raspberry Pi
Docker installed on your Raspberry Pi
Run Node-RED in a Docker Container
Pull the Node-RED Docker image:
Create a named data volume to persist Node-RED data
Run the Node-RED container
This command does the following:
-it
: Runs the container in interactive mode with a terminal attached.-p
1880:1880
: Maps the container's port 1880 to the host's port 1880.-v
node_red_data:/data
: Mounts the named data volumenode_red_data
to the container's/data
directory.--name mynodered
: Assigns a friendly name to the container.nodered/node-red
: Specifies the Docker image to use.
Access Node-RED in a web browser by opening http://<raspberry-pi-ip>:1880
, replacing <raspberry-pi-ip>
with the IP address of your Raspberry Pi.
Wally's IP Address for Raspberry Pi
Managing the Node-RED Container
To stop the Node-RED container:
To start the Node-RED container:
To restart the Node-RED container:
To remove the Node-RED container (the data will persist in the named volume):
To install additional Node-RED nodes, you can access the container's shell
Once inside the container, you can use npm to install nodes:
To customize Node-RED settings, you can create a settings.js
file on the host and mount it into the container:
Replace /path/to/settings.js
with the actual path to your settings.js
file.
To access the host's GPIO pins from within the Node-RED container, you can use the --device
flag to pass the device access through:
Note: This requires the node-red-node-pi-gpiod
nodes to be installed and configured to connect to the host's PiGPIOd daemon.
Using Docker Compose (Optional) Docker Compose simplifies the management of containers by allowing you to define and run multi-container applications with a single command.
Create a docker-compose.yml
file with the following content:
Save the file and run the following command to start Node-RED
The -d
flag runs the containers in detached mode.
To stop the Node-RED container started with Docker Compose
Conclusion
Running Node-RED in a Docker container on a Raspberry Pi 5 with a 64-bit ARM architecture provides a convenient and reproducible way to deploy and manage Node-RED instances.
Docker allows you to easily update, customise, and scale your Node-RED deployments while keeping your data persisted in named volumes.
With this setup, you can take advantage of the powerful features of Node-RED on your Raspberry Pi, such as building IoT applications, automating tasks, and integrating various services and devices.
Remember to regularly update your Node-RED container to benefit from the latest features, bug fixes, and security patches.
Last updated
Was this helpful?