Skip to content
Stand with Ukraine flag

Cluster setup using Docker Compose

This guide walks you through setting up ThingsBoard Community Edition in cluster mode using Docker Compose with microservices architecture.

For a simpler single-node installation, see Docker (Linux, macOS).

Install Docker:

A server with at least 8 GB of RAM (16 GB recommended for production cluster deployments).

Make sure you have logged in to Docker Hub using the command line.

Terminal window
docker pull thingsboard/tb-node:4.3.1.1
docker pull thingsboard/tb-web-ui:4.3.1.1
docker pull thingsboard/tb-js-executor:4.3.1.1
docker pull thingsboard/tb-http-transport:4.3.1.1
docker pull thingsboard/tb-mqtt-transport:4.3.1.1
docker pull thingsboard/tb-coap-transport:4.3.1.1
docker pull thingsboard/tb-lwm2m-transport:4.3.1.1
docker pull thingsboard/tb-snmp-transport:4.3.1.1
Terminal window
git clone -b release-4.3 https://github.com/thingsboard/thingsboard.git --depth 1
cd thingsboard/docker

Edit the .env file to set the database type:

Terminal window
nano .env

Set the DATABASE variable to one of:

ValueDescription
postgresUse PostgreSQL for all data
hybridUse PostgreSQL for entities and Cassandra for time-series data

ThingsBoard cluster deployments require an external message broker. In Memory queue is not suitable for cluster mode.

  • Kafka — recommended for production. Used on most ThingsBoard production environments. Works for on-prem and private cloud deployments.
  • Confluent Cloud — fully managed streaming platform based on Kafka. Useful for cloud-agnostic deployments.

Apache Kafka is an open-source stream-processing platform.

Edit the .env file:

Terminal window
nano .env

Verify the following line:

Terminal window
TB_QUEUE_TYPE=kafka

Edit the .env file:

Terminal window
nano .env

Set MONITORING_ENABLED to true:

Terminal window
MONITORING_ENABLED=true

After deployment, Prometheus will be available at http://localhost:9090 and Grafana at http://localhost:3000 (default login: admin / foobar).

Create log folders for the services. The script requires sudo permissions to change ownership:

Terminal window
./docker-create-log-folders.sh

Verify that all required volume folders are available and have correct ownership:

Terminal window
./docker-check-log-folders.sh
Terminal window
./docker-install-tb.sh --loadDemo

The --loadDemo flag loads sample tenant account, dashboards, and devices for evaluation and testing.

Terminal window
./docker-start-services.sh

After a while when all services are started, open http://localhost in your browser. You should see the ThingsBoard login page. Use the following default credentials:

You can change passwords for each account in the account profile page.

See Getting Started for your next steps after login.

Stream ThingsBoard node logs:

Terminal window
docker compose logs -f tb-core1 tb-rule-engine1

View the state of all containers:

Terminal window
docker compose ps

Stream logs of all services:

Terminal window
docker compose logs -f

Stop all services:

Terminal window
./docker-stop-services.sh

Remove all deployed containers:

Terminal window
./docker-remove-services.sh

Update specific services (pull newer image and rebuild container):

Terminal window
./docker-update-service.sh [SERVICE...]

If [SERVICE...] is omitted, all services are updated.

The deployment uses HAProxy for proxying traffic to containers. By default ports 80 and 443 are used. To use HTTPS with a valid certificate:

Terminal window
docker exec haproxy-certbot certbot-certonly --domain your_domain --email your_email
docker exec haproxy-certbot haproxy-refresh

When a new ThingsBoard release becomes available, update your installation to benefit from the latest features and security patches.

See the Upgrade Instructions for detailed steps.

If you observe errors related to DNS issues, for example:

Terminal window
127.0.1.1:53: cannot unmarshal DNS message

Configure your system to use Google public DNS servers. See Linux and macOS instructions.