docker.recipes

ThingsBoard IoT Platform

advanced

Open-source IoT platform for device management, data collection, and visualization.

Overview

ThingsBoard is an open-source IoT platform developed to simplify the collection, processing, and visualization of telemetry data from connected devices. Originally created in 2016 by the ThingsBoard team, it has evolved into a comprehensive solution that handles device management, data collection, rule processing, and dashboard creation for IoT deployments ranging from small prototypes to enterprise-scale implementations. The platform supports multiple communication protocols including MQTT, CoAP, HTTP, and LWM2M, making it versatile for diverse IoT ecosystems. This stack combines ThingsBoard with PostgreSQL as the primary database for storing device data and metadata, Redis for caching and session management to improve response times, and Eclipse Mosquitto as an external MQTT broker for device communication. PostgreSQL provides the robust data integrity and complex querying capabilities needed for time-series telemetry data and device relationships, while Redis accelerates frequent operations like dashboard loading and real-time data access. The inclusion of Mosquitto as a separate MQTT broker allows for more granular control over device connectivity and can handle high-frequency telemetry ingestion independently of the main ThingsBoard container. This configuration is ideal for IoT developers, system integrators, and organizations looking to deploy a complete device management platform without the complexity of cloud vendor lock-in. The stack provides everything needed to onboard devices, create data visualization dashboards, set up alerting rules, and manage device firmware updates, making it particularly valuable for industrial IoT applications, smart building management, and environmental monitoring systems where data sovereignty and customization are priorities.

Key Features

  • Multi-protocol device connectivity supporting MQTT, CoAP, HTTP, and LWM2M for diverse IoT device ecosystems
  • Advanced rule engine with visual flow-based programming for processing telemetry data and triggering actions
  • Time-series data storage in PostgreSQL optimized for high-frequency sensor data ingestion and historical analysis
  • Real-time dashboard builder with customizable widgets for gauges, charts, maps, and device controls
  • Device provisioning and management with support for device profiles, credentials, and over-the-air updates
  • Redis-accelerated data access for sub-second dashboard loading and real-time telemetry visualization
  • Built-in alarm system with configurable thresholds, severity levels, and notification channels
  • Multi-tenancy support with customer hierarchy, user roles, and resource isolation for managed IoT services

Common Use Cases

  • 1Industrial IoT monitoring for manufacturing equipment with predictive maintenance alerts and production dashboards
  • 2Smart building automation managing HVAC, lighting, and security sensors with centralized control interfaces
  • 3Environmental monitoring networks collecting air quality, weather, and pollution data across multiple locations
  • 4Fleet management systems tracking vehicle telemetry, GPS coordinates, and maintenance schedules
  • 5Agricultural IoT deployments monitoring soil moisture, temperature, and irrigation systems for precision farming
  • 6Energy management platforms collecting data from smart meters, solar panels, and battery storage systems
  • 7Home automation labs integrating various smart devices with custom dashboards and automation rules

Prerequisites

  • Minimum 4GB RAM recommended for ThingsBoard with PostgreSQL time-series data and concurrent device connections
  • Available ports 8080 (web interface), 1883/1884 (MQTT), 7070 (RPC), and 5683-5688 (CoAP/UDP)
  • Basic understanding of MQTT protocol and IoT device communication patterns
  • Familiarity with time-series data concepts and PostgreSQL for advanced rule engine configuration
  • Knowledge of JSON message formats for device telemetry and attribute payloads
  • Understanding of SSL/TLS certificates if planning to secure MQTT and web interface communications

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 thingsboard:
3 image: thingsboard/tb-postgres:latest
4 ports:
5 - "8080:9090"
6 - "1883:1883"
7 - "7070:7070"
8 - "5683-5688:5683-5688/udp"
9 environment:
10 TB_QUEUE_TYPE: in-memory
11 volumes:
12 - thingsboard_data:/data
13 - thingsboard_logs:/var/log/thingsboard
14 networks:
15 - tb-net
16 restart: unless-stopped
17
18 postgres:
19 image: postgres:16-alpine
20 environment:
21 POSTGRES_USER: ${POSTGRES_USER}
22 POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
23 POSTGRES_DB: thingsboard
24 volumes:
25 - postgres_data:/var/lib/postgresql/data
26 networks:
27 - tb-net
28 restart: unless-stopped
29
30 redis:
31 image: redis:7-alpine
32 volumes:
33 - redis_data:/data
34 networks:
35 - tb-net
36 restart: unless-stopped
37
38 mosquitto:
39 image: eclipse-mosquitto:latest
40 ports:
41 - "1884:1883"
42 - "9001:9001"
43 volumes:
44 - ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
45 - mosquitto_data:/mosquitto/data
46 - mosquitto_log:/mosquitto/log
47 networks:
48 - tb-net
49 restart: unless-stopped
50
51volumes:
52 thingsboard_data:
53 thingsboard_logs:
54 postgres_data:
55 redis_data:
56 mosquitto_data:
57 mosquitto_log:
58
59networks:
60 tb-net:
61 driver: bridge

.env Template

.env
1# PostgreSQL
2POSTGRES_USER=thingsboard
3POSTGRES_PASSWORD=secure_postgres_password

Usage Notes

  1. 1ThingsBoard at http://localhost:8080
  2. 2Default login: tenant@thingsboard.org / tenant
  3. 3MQTT broker at localhost:1883
  4. 4CoAP at localhost:5683

Individual Services(4 services)

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

thingsboard
thingsboard:
  image: thingsboard/tb-postgres:latest
  ports:
    - "8080:9090"
    - "1883:1883"
    - "7070:7070"
    - 5683-5688:5683-5688/udp
  environment:
    TB_QUEUE_TYPE: in-memory
  volumes:
    - thingsboard_data:/data
    - thingsboard_logs:/var/log/thingsboard
  networks:
    - tb-net
  restart: unless-stopped
postgres
postgres:
  image: postgres:16-alpine
  environment:
    POSTGRES_USER: ${POSTGRES_USER}
    POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    POSTGRES_DB: thingsboard
  volumes:
    - postgres_data:/var/lib/postgresql/data
  networks:
    - tb-net
  restart: unless-stopped
redis
redis:
  image: redis:7-alpine
  volumes:
    - redis_data:/data
  networks:
    - tb-net
  restart: unless-stopped
mosquitto
mosquitto:
  image: eclipse-mosquitto:latest
  ports:
    - "1884:1883"
    - "9001:9001"
  volumes:
    - ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
    - mosquitto_data:/mosquitto/data
    - mosquitto_log:/mosquitto/log
  networks:
    - tb-net
  restart: unless-stopped

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 thingsboard:
5 image: thingsboard/tb-postgres:latest
6 ports:
7 - "8080:9090"
8 - "1883:1883"
9 - "7070:7070"
10 - "5683-5688:5683-5688/udp"
11 environment:
12 TB_QUEUE_TYPE: in-memory
13 volumes:
14 - thingsboard_data:/data
15 - thingsboard_logs:/var/log/thingsboard
16 networks:
17 - tb-net
18 restart: unless-stopped
19
20 postgres:
21 image: postgres:16-alpine
22 environment:
23 POSTGRES_USER: ${POSTGRES_USER}
24 POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
25 POSTGRES_DB: thingsboard
26 volumes:
27 - postgres_data:/var/lib/postgresql/data
28 networks:
29 - tb-net
30 restart: unless-stopped
31
32 redis:
33 image: redis:7-alpine
34 volumes:
35 - redis_data:/data
36 networks:
37 - tb-net
38 restart: unless-stopped
39
40 mosquitto:
41 image: eclipse-mosquitto:latest
42 ports:
43 - "1884:1883"
44 - "9001:9001"
45 volumes:
46 - ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
47 - mosquitto_data:/mosquitto/data
48 - mosquitto_log:/mosquitto/log
49 networks:
50 - tb-net
51 restart: unless-stopped
52
53volumes:
54 thingsboard_data:
55 thingsboard_logs:
56 postgres_data:
57 redis_data:
58 mosquitto_data:
59 mosquitto_log:
60
61networks:
62 tb-net:
63 driver: bridge
64EOF
65
66# 2. Create the .env file
67cat > .env << 'EOF'
68# PostgreSQL
69POSTGRES_USER=thingsboard
70POSTGRES_PASSWORD=secure_postgres_password
71EOF
72
73# 3. Start the services
74docker compose up -d
75
76# 4. View logs
77docker 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/thingsboard-iot/run | bash

Troubleshooting

  • ThingsBoard fails to start with database connection errors: Ensure PostgreSQL container is fully initialized before ThingsBoard starts, add depends_on with health checks
  • Devices cannot connect via MQTT with authentication failures: Verify device credentials in ThingsBoard device management and check MQTT broker logs for connection attempts
  • Dashboard widgets show 'No data' despite device connectivity: Check device telemetry keys match widget data key configuration and verify time range settings
  • High memory usage and slow dashboard loading: Increase Redis memory allocation and enable ThingsBoard caching configuration in environment variables
  • Rule engine chains not triggering properly: Verify rule node connections and check ThingsBoard logs for rule processing errors and message flow debugging
  • CoAP devices timing out during communication: Ensure UDP port range 5683-5688 is properly exposed and check firewall settings for UDP traffic

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