docker.recipes

Node-RED Automation Platform

intermediate

Low-code automation with Node-RED, MQTT broker, InfluxDB storage, and Grafana dashboards.

Overview

Node-RED is a visual programming tool developed by IBM that enables users to wire together hardware devices, APIs, and online services through a browser-based flow editor. Built on Node.js, it uses a drag-and-drop interface where users connect nodes to create automation flows, making it particularly valuable for IoT applications, home automation, and industrial monitoring without requiring extensive coding knowledge. This automation platform combines Node-RED with Mosquitto MQTT broker for lightweight messaging, InfluxDB for time-series data storage, and Grafana for creating rich visualization dashboards. The stack creates a complete data pipeline where sensors and devices publish data via MQTT, Node-RED processes and routes this information to InfluxDB for storage, while Grafana provides real-time monitoring and historical analysis through customizable dashboards. This combination is ideal for makers, system integrators, and organizations looking to implement comprehensive IoT automation solutions. The visual programming approach of Node-RED makes complex automation accessible to users with varying technical backgrounds, while the time-series capabilities of InfluxDB and visualization power of Grafana provide enterprise-grade monitoring and analytics capabilities typically found in much more expensive commercial solutions.

Key Features

  • Visual flow-based programming with 300+ pre-built nodes for common automation tasks
  • MQTT broker with WebSocket support for real-time IoT device communication
  • InfluxDB 2.7 with Flux query language for advanced time-series data analysis
  • Grafana dashboard templating with variables for dynamic multi-device monitoring
  • Node-RED palette manager for installing community-contributed automation nodes
  • Mosquitto persistence and retained message support for reliable IoT messaging
  • InfluxDB data retention policies for automatic old data cleanup
  • Grafana alerting with multiple notification channels including Slack and email

Common Use Cases

  • 1Home automation systems collecting sensor data and controlling smart devices
  • 2Industrial IoT monitoring for equipment performance and predictive maintenance
  • 3Weather station data collection with automated alerts for extreme conditions
  • 4Energy monitoring systems tracking solar panel output and consumption patterns
  • 5Greenhouse automation with temperature, humidity, and irrigation control
  • 6Network monitoring solutions collecting SNMP data and system metrics
  • 7Building management systems for HVAC control and occupancy tracking

Prerequisites

  • Docker Engine 20.10+ and Docker Compose V2 for container orchestration
  • Minimum 2GB RAM (1GB for InfluxDB, 512MB for Grafana, remainder for Node-RED and Mosquitto)
  • Available ports 1880 (Node-RED), 1883/9001 (MQTT), 3000 (Grafana), and 8086 (InfluxDB)
  • Basic understanding of MQTT publish/subscribe messaging patterns
  • Familiarity with time-series data concepts for effective InfluxDB usage
  • Knowledge of JSON data structures for Node-RED flow configuration

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 nodered:
3 image: nodered/node-red:latest
4 environment:
5 TZ: ${TZ}
6 ports:
7 - "1880:1880"
8 volumes:
9 - nodered_data:/data
10 depends_on:
11 - mosquitto
12 networks:
13 - automation-net
14 restart: unless-stopped
15
16 mosquitto:
17 image: eclipse-mosquitto:latest
18 ports:
19 - "1883:1883"
20 - "9001:9001"
21 volumes:
22 - ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
23 - mosquitto_data:/mosquitto/data
24 networks:
25 - automation-net
26 restart: unless-stopped
27
28 influxdb:
29 image: influxdb:2.7
30 environment:
31 DOCKER_INFLUXDB_INIT_MODE: setup
32 DOCKER_INFLUXDB_INIT_USERNAME: ${INFLUX_USER}
33 DOCKER_INFLUXDB_INIT_PASSWORD: ${INFLUX_PASSWORD}
34 DOCKER_INFLUXDB_INIT_ORG: ${INFLUX_ORG}
35 DOCKER_INFLUXDB_INIT_BUCKET: ${INFLUX_BUCKET}
36 ports:
37 - "8086:8086"
38 volumes:
39 - influxdb_data:/var/lib/influxdb2
40 networks:
41 - automation-net
42 restart: unless-stopped
43
44 grafana:
45 image: grafana/grafana:latest
46 environment:
47 GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_PASSWORD}
48 ports:
49 - "3000:3000"
50 volumes:
51 - grafana_data:/var/lib/grafana
52 depends_on:
53 - influxdb
54 networks:
55 - automation-net
56 restart: unless-stopped
57
58volumes:
59 nodered_data:
60 mosquitto_data:
61 influxdb_data:
62 grafana_data:
63
64networks:
65 automation-net:
66 driver: bridge

.env Template

.env
1# Timezone
2TZ=UTC
3
4# InfluxDB
5INFLUX_USER=admin
6INFLUX_PASSWORD=secure_influx_password
7INFLUX_ORG=automation
8INFLUX_BUCKET=nodered
9
10# Grafana
11GRAFANA_PASSWORD=secure_grafana_password

Usage Notes

  1. 1Node-RED editor at http://localhost:1880
  2. 2Install additional nodes from palette manager
  3. 3Use MQTT nodes for IoT integration
  4. 4Visualize data in Grafana

Individual Services(4 services)

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

nodered
nodered:
  image: nodered/node-red:latest
  environment:
    TZ: ${TZ}
  ports:
    - "1880:1880"
  volumes:
    - nodered_data:/data
  depends_on:
    - mosquitto
  networks:
    - automation-net
  restart: unless-stopped
mosquitto
mosquitto:
  image: eclipse-mosquitto:latest
  ports:
    - "1883:1883"
    - "9001:9001"
  volumes:
    - ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
    - mosquitto_data:/mosquitto/data
  networks:
    - automation-net
  restart: unless-stopped
influxdb
influxdb:
  image: influxdb:2.7
  environment:
    DOCKER_INFLUXDB_INIT_MODE: setup
    DOCKER_INFLUXDB_INIT_USERNAME: ${INFLUX_USER}
    DOCKER_INFLUXDB_INIT_PASSWORD: ${INFLUX_PASSWORD}
    DOCKER_INFLUXDB_INIT_ORG: ${INFLUX_ORG}
    DOCKER_INFLUXDB_INIT_BUCKET: ${INFLUX_BUCKET}
  ports:
    - "8086:8086"
  volumes:
    - influxdb_data:/var/lib/influxdb2
  networks:
    - automation-net
  restart: unless-stopped
grafana
grafana:
  image: grafana/grafana:latest
  environment:
    GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_PASSWORD}
  ports:
    - "3000:3000"
  volumes:
    - grafana_data:/var/lib/grafana
  depends_on:
    - influxdb
  networks:
    - automation-net
  restart: unless-stopped

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 nodered:
5 image: nodered/node-red:latest
6 environment:
7 TZ: ${TZ}
8 ports:
9 - "1880:1880"
10 volumes:
11 - nodered_data:/data
12 depends_on:
13 - mosquitto
14 networks:
15 - automation-net
16 restart: unless-stopped
17
18 mosquitto:
19 image: eclipse-mosquitto:latest
20 ports:
21 - "1883:1883"
22 - "9001:9001"
23 volumes:
24 - ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
25 - mosquitto_data:/mosquitto/data
26 networks:
27 - automation-net
28 restart: unless-stopped
29
30 influxdb:
31 image: influxdb:2.7
32 environment:
33 DOCKER_INFLUXDB_INIT_MODE: setup
34 DOCKER_INFLUXDB_INIT_USERNAME: ${INFLUX_USER}
35 DOCKER_INFLUXDB_INIT_PASSWORD: ${INFLUX_PASSWORD}
36 DOCKER_INFLUXDB_INIT_ORG: ${INFLUX_ORG}
37 DOCKER_INFLUXDB_INIT_BUCKET: ${INFLUX_BUCKET}
38 ports:
39 - "8086:8086"
40 volumes:
41 - influxdb_data:/var/lib/influxdb2
42 networks:
43 - automation-net
44 restart: unless-stopped
45
46 grafana:
47 image: grafana/grafana:latest
48 environment:
49 GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_PASSWORD}
50 ports:
51 - "3000:3000"
52 volumes:
53 - grafana_data:/var/lib/grafana
54 depends_on:
55 - influxdb
56 networks:
57 - automation-net
58 restart: unless-stopped
59
60volumes:
61 nodered_data:
62 mosquitto_data:
63 influxdb_data:
64 grafana_data:
65
66networks:
67 automation-net:
68 driver: bridge
69EOF
70
71# 2. Create the .env file
72cat > .env << 'EOF'
73# Timezone
74TZ=UTC
75
76# InfluxDB
77INFLUX_USER=admin
78INFLUX_PASSWORD=secure_influx_password
79INFLUX_ORG=automation
80INFLUX_BUCKET=nodered
81
82# Grafana
83GRAFANA_PASSWORD=secure_grafana_password
84EOF
85
86# 3. Start the services
87docker compose up -d
88
89# 4. View logs
90docker 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-automation/run | bash

Troubleshooting

  • Node-RED flows not connecting to Mosquitto: Verify MQTT broker configuration node uses 'mosquitto' as hostname, not localhost
  • InfluxDB authentication errors: Check DOCKER_INFLUXDB_INIT_* environment variables match values used in Node-RED InfluxDB output nodes
  • Grafana showing 'No data points' for InfluxDB queries: Ensure InfluxDB data source uses Flux language and correct bucket name from environment variables
  • MQTT clients cannot connect: Create mosquitto.conf file with 'listener 1883' and 'allow_anonymous true' for basic setup
  • Node-RED palette installation fails: Container needs internet access and sufficient disk space in nodered_data volume
  • Grafana dashboards not persisting: Verify grafana_data volume is properly mounted and container has write permissions

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