docker.recipes

Node-RED IoT Platform

beginner

Node-RED flow-based programming for IoT with MQTT broker.

Overview

Node-RED is an open-source flow-based visual programming tool originally developed by IBM for wiring together hardware devices, APIs, and online services in IoT applications. Built on Node.js, it provides a browser-based flow editor that makes it easy to create event-driven applications using a wide range of pre-built nodes. The platform excels at rapid prototyping and deployment of IoT solutions, home automation systems, and data processing workflows without requiring traditional programming skills. This stack combines Node-RED with Eclipse Mosquitto, a lightweight MQTT message broker that implements the MQTT protocol versions 5.0, 3.1.1, and 3.1. Mosquitto serves as the central communication hub for IoT devices, while Node-RED acts as the orchestration layer, processing MQTT messages and triggering automated responses. The integration enables real-time data collection from sensors, device control commands, and complex automation logic through Node-RED's visual drag-and-drop interface. This configuration is ideal for IoT enthusiasts, home automation builders, and small-scale industrial deployments who need a powerful yet approachable platform for connecting and controlling smart devices. The combination provides enterprise-grade MQTT messaging capabilities with the flexibility of visual flow programming, making it accessible to both technical and non-technical users who want to build sophisticated IoT applications.

Key Features

  • Flow-based visual programming with drag-and-drop node editor for creating IoT automation logic
  • Built-in MQTT nodes for seamless publish/subscribe messaging with Mosquitto broker
  • Over 4,000 community-contributed nodes available through npm for extending functionality
  • Real-time dashboard creation with gauge, chart, and control widgets for IoT monitoring
  • Function nodes supporting JavaScript for custom data processing and transformation
  • WebSocket support for real-time browser-based device interaction and monitoring
  • Eclipse Mosquitto MQTT 5.0 compliance with quality of service levels and retained messages
  • Persistent flow storage with automatic backup and version control capabilities

Common Use Cases

  • 1Home automation systems controlling smart lights, thermostats, and security sensors via MQTT
  • 2Industrial IoT monitoring with sensor data collection and equipment status dashboards
  • 3Greenhouse automation managing irrigation, climate control, and environmental monitoring
  • 4Smart building management integrating HVAC, lighting, and occupancy sensors
  • 5Weather station data aggregation with automated alerts and historical data logging
  • 6Fleet vehicle tracking and monitoring using GPS and telemetry data over MQTT
  • 7Energy monitoring systems tracking solar panels, battery storage, and consumption patterns

Prerequisites

  • Docker Engine 20.10+ and Docker Compose V2 for container orchestration
  • Minimum 512MB RAM for Node-RED container and 256MB for Mosquitto broker
  • Available ports 1880 (Node-RED), 1883 (MQTT), and 9001 (MQTT WebSocket)
  • Basic understanding of MQTT publish/subscribe messaging concepts
  • Mosquitto configuration file (mosquitto.conf) with authentication and access control settings
  • Network access for downloading Node-RED community nodes from npm registry

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 mosquitto:
3 image: eclipse-mosquitto:latest
4 container_name: mosquitto
5 restart: unless-stopped
6 ports:
7 - "${MQTT_PORT:-1883}:1883"
8 - "${MQTT_WS_PORT:-9001}:9001"
9 volumes:
10 - mosquitto_data:/mosquitto/data
11 - mosquitto_log:/mosquitto/log
12 - ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
13 networks:
14 - iot-network
15
16 node-red:
17 image: nodered/node-red:latest
18 container_name: node-red
19 restart: unless-stopped
20 ports:
21 - "${NODERED_PORT:-1880}:1880"
22 environment:
23 - TZ=${TZ:-UTC}
24 volumes:
25 - nodered_data:/data
26 depends_on:
27 - mosquitto
28 networks:
29 - iot-network
30
31volumes:
32 mosquitto_data:
33 mosquitto_log:
34 nodered_data:
35
36networks:
37 iot-network:
38 driver: bridge

.env Template

.env
1# Node-RED IoT
2NODERED_PORT=1880
3MQTT_PORT=1883
4MQTT_WS_PORT=9001
5TZ=UTC

Usage Notes

  1. 1Node-RED at http://localhost:1880
  2. 2MQTT broker at localhost:1883
  3. 3Create mosquitto.conf before starting
  4. 4Install MQTT nodes in Node-RED

Individual Services(2 services)

Copy individual services to mix and match with your existing compose files.

mosquitto
mosquitto:
  image: eclipse-mosquitto:latest
  container_name: mosquitto
  restart: unless-stopped
  ports:
    - ${MQTT_PORT:-1883}:1883
    - ${MQTT_WS_PORT:-9001}:9001
  volumes:
    - mosquitto_data:/mosquitto/data
    - mosquitto_log:/mosquitto/log
    - ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
  networks:
    - iot-network
node-red
node-red:
  image: nodered/node-red:latest
  container_name: node-red
  restart: unless-stopped
  ports:
    - ${NODERED_PORT:-1880}:1880
  environment:
    - TZ=${TZ:-UTC}
  volumes:
    - nodered_data:/data
  depends_on:
    - mosquitto
  networks:
    - iot-network

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 mosquitto:
5 image: eclipse-mosquitto:latest
6 container_name: mosquitto
7 restart: unless-stopped
8 ports:
9 - "${MQTT_PORT:-1883}:1883"
10 - "${MQTT_WS_PORT:-9001}:9001"
11 volumes:
12 - mosquitto_data:/mosquitto/data
13 - mosquitto_log:/mosquitto/log
14 - ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
15 networks:
16 - iot-network
17
18 node-red:
19 image: nodered/node-red:latest
20 container_name: node-red
21 restart: unless-stopped
22 ports:
23 - "${NODERED_PORT:-1880}:1880"
24 environment:
25 - TZ=${TZ:-UTC}
26 volumes:
27 - nodered_data:/data
28 depends_on:
29 - mosquitto
30 networks:
31 - iot-network
32
33volumes:
34 mosquitto_data:
35 mosquitto_log:
36 nodered_data:
37
38networks:
39 iot-network:
40 driver: bridge
41EOF
42
43# 2. Create the .env file
44cat > .env << 'EOF'
45# Node-RED IoT
46NODERED_PORT=1880
47MQTT_PORT=1883
48MQTT_WS_PORT=9001
49TZ=UTC
50EOF
51
52# 3. Start the services
53docker compose up -d
54
55# 4. View logs
56docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/node-red-iot/run | bash

Troubleshooting

  • Node-RED flows not saving: Check that the /data volume has proper write permissions and sufficient disk space
  • MQTT clients cannot connect to Mosquitto: Verify mosquitto.conf allows anonymous connections or configure proper authentication
  • Node-RED MQTT nodes show 'disconnected': Ensure Mosquitto container is running and check network connectivity between containers
  • WebSocket connections failing on port 9001: Confirm Mosquitto configuration includes WebSocket listener and port is not blocked by firewall
  • Node-RED dashboard not loading: Clear browser cache and check that ui nodes are properly installed and configured
  • High memory usage in Node-RED: Reduce debug node output retention and limit the number of active dashboard charts

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Ad Space