Skip to content
Stand with Ukraine flag

Docker (Linux & macOS)

This guide describes how to install and start a standalone TBMQ instance using Docker on Linux or macOS. For cluster installation, see the cluster setup page.

The install script runs TBMQ, PostgreSQL, Kafka, Valkey, and the Integration Executor as Docker containers on one host. Once it is running, TBMQ listens on these ports:

One host · Docker

  • TBMQ
  • Integration Executor
  • PostgreSQL
  • Kafka
  • Valkey

Ports

  • 8083 HTTP TBMQ UI and REST API
  • 1883 MQTT MQTT clients
  • 8084 MQTT over WebSockets MQTT clients that connect over WebSockets
  • 8883 MQTTS MQTT clients that connect over TLS, once you enable MQTTS
  • At least 2 GB of RAM.
  • Docker installed.

Installation takes two steps: run the install script, then log in to the TBMQ UI.

Run the following commands to download and run the TBMQ install script:

Terminal window
wget https://raw.githubusercontent.com/thingsboard/tbmq/release-2.4.2/msa/tbmq/configs/tbmq-install-and-run.sh &&
chmod +x tbmq-install-and-run.sh && ./tbmq-install-and-run.sh

The script downloads the docker-compose.yml file if it is not already in the current directory, creates the necessary Docker volumes, installs the database, and starts TBMQ. It then follows the container logs; press Ctrl+C to stop following them — TBMQ keeps running.

Key configuration points in the docker-compose.yml
Setting Purpose
8083:8083 Exposes the HTTP UI on port 8083
1883:1883 Exposes the MQTT port 1883
8084:8084 Exposes MQTT over WebSockets on port 8084
tbmq-valkey-data:/data Valkey data volume
tbmq-postgres-data:/var/lib/postgresql/data PostgreSQL data volume
tbmq-kafka-data:/var/lib/kafka/data Kafka data volume
tbmq-kafka-secrets:/etc/kafka/secrets, tbmq-kafka-config:/mnt/shared/config Kafka secrets and configuration volumes
tbmq-logs:/var/log/thingsboard-mqtt-broker TBMQ logs volume
tbmq-data:/data TBMQ data directory (contains .firstlaunch after DB installation)
tbmq-ie-logs:/var/log/tbmq-integration-executor Integration Executor logs volume
tbmq Docker service name
tbmq-integration-executor Docker service name of the Integration Executor, which runs integrations
restart: always Auto-restarts TBMQ on system reboot or failure
  1. Open the UI.

    Once installation is complete, access the TBMQ UI at http://{your-host-ip}:8083 in your browser (e.g., http://localhost:8083). You should see the TBMQ login page.

  2. Sign in as System Administrator.

    Use the default System Administrator credentials:

    Username
    sysadmin@thingsboard.org
    Password
    sysadmin
  3. Change the default password.

    On first login, you are prompted to change the default password and re-login with the new credentials.

Run these commands from the directory that contains docker-compose.yml.

View TBMQ logs
docker compose logs -f tbmq
Stop the containers
docker compose stop
Start the containers
docker compose start
  1. Check the version-specific notes below for any preparation your target version requires.
  2. Back up your database (optional but recommended).
  3. Run the upgrade command.

For full version history and supported upgrade paths, see the upgrade instructions page. If the documentation does not cover your specific upgrade path, contact us for guidance.

What each upgrade needs before you run the script — select a version for its full notes:

Upgrade to Before running the upgrade script
2.4.2 Create an empty .tbmq-upgrade.env. Check SCRAM-only authentication and Kafka integrations
2.4.1 Create an empty .tbmq-upgrade.env. If you set MQTT_TOPIC_MAX_SEGMENTS_COUNT, raise it by 1
2.4.0 Create an empty .tbmq-upgrade.env. If you scrape metrics, update queries for the renamed Prometheus metrics
2.3.0 Replace docker-compose.yml, migrate or empty the PostgreSQL and Kafka volumes, create the new volumes, and create an empty .tbmq-upgrade.env
2.2.0 Create .tbmq-upgrade.env with your authentication settings
2.1.0 Add the Integration Executor service and upgrade the third-party services
2.0.0 Add the Redis service

Backing up your PostgreSQL database before upgrading is highly recommended but optional. For further guidance, follow the backup and restore instructions.

This is a standard upgrade from v2.4.1. No third-party component changes are required, and the upgrade only records the new schema version — no table is created or altered and no data is migrated.

The upgrade script requires a .tbmq-upgrade.env file. If it does not already exist from a previous upgrade, create an empty one:

Terminal window
touch .tbmq-upgrade.env

Then proceed with the upgrade.

This is a standard upgrade from v2.4.0.

No third-party component changes are required, and the upgrade only records the new schema version — no table is created or altered and no data is migrated.

The upgrade script requires a .tbmq-upgrade.env file. If it does not already exist from a previous upgrade, create an empty one:

Terminal window
touch .tbmq-upgrade.env

Then proceed with the upgrade.

This is a standard upgrade from v2.3.0.

No third-party component changes are required.

The upgrade script requires a .tbmq-upgrade.env file. If it does not already exist from a previous upgrade, create an empty one:

Terminal window
touch .tbmq-upgrade.env

Then proceed with the upgrade.

This release migrates all third-party components from Bitnami images to official open-source alternatives.

Review the third-party component updates for full details.

The 2.3.0 upgrade script changes only the tbmq and tbmq-integration-executor image tags, and runs the database upgrade against a Valkey service named valkey. Before running it, replace your docker-compose.yml with the 2.3.0 version, carrying over your own changes. The new file keeps the tbmq-postgres-data and tbmq-kafka-data volume names but runs PostgreSQL 17 and Apache Kafka on them, so migrate or empty those volumes first, as the upgrade notes describe. Then create the new volumes:

Terminal window
docker volume create tbmq-kafka-secrets
docker volume create tbmq-kafka-config
docker volume create tbmq-valkey-data

The upgrade script requires a .tbmq-upgrade.env file. If it does not already exist from a previous upgrade, create an empty one:

Terminal window
touch .tbmq-upgrade.env

Then proceed with the upgrade.

This release migrates MQTT authentication from YAML/env configuration into the database.

The upgrade script requires a .tbmq-upgrade.env file in the same directory as docker-compose.yml. The values must match the authentication settings in your tbmq service environment.

Create the env file

Terminal window
cat > .tbmq-upgrade.env <<'EOF'
SECURITY_MQTT_BASIC_ENABLED=true
SECURITY_MQTT_SSL_ENABLED=false
SECURITY_MQTT_SSL_SKIP_VALIDITY_CHECK_FOR_CLIENT_CERT=false
EOF

The example matches the default docker-compose.yml, which enables only Basic authentication.

Notes

  • Required: If .tbmq-upgrade.env is missing, the upgrade script will fail.
  • Supported variables:
    • SECURITY_MQTT_BASIC_ENABLED (true|false)
    • SECURITY_MQTT_SSL_ENABLED (true|false)
    • SECURITY_MQTT_SSL_SKIP_VALIDITY_CHECK_FOR_CLIENT_CERT (true|false) — usually false

Once the file is created, proceed with the upgrade.

This release adds the Integration Executor microservice and updates third-party service versions.

Add Integration Executor microservice

Add the Integration Executor service definition and volume to your docker-compose.yml (full example):

Service definition and volume
tbmq-integration-executor:
restart: always
image: "thingsboard/tbmq-integration-executor:2.1.0"
depends_on:
- kafka
- tbmq
logging:
driver: "json-file"
options:
max-size: "200m"
max-file: "5"
environment:
TB_SERVICE_ID: tbmq-ie
TB_KAFKA_SERVERS: kafka:9092
#JAVA_OPTS: "-Xmx2048M -Xms2048M -Xss384k -XX:+AlwaysPreTouch"
volumes:
- tbmq-ie-logs:/var/log/tbmq-integration-executor
volumes:
tbmq-ie-logs:
external: true

Create the log volume and start the service:

Terminal window
docker volume create tbmq-ie-logs
docker compose up -d tbmq-integration-executor --no-deps

Update third-party services

This release updates third-party dependency versions (pull request):

Service Previous version Updated version
Redis 7.0 7.2.5
PostgreSQL 15.x 16.x
Kafka 3.5.1 3.7.0

After addressing third-party service versions, proceed with the upgrade.

This release adds Redis configuration to the Docker Compose setup.

Update your docker-compose.yml to include the Redis service (pull request diff).

Complete Docker Compose file prior to the upgrade
#
# Copyright © 2016-2024 The Thingsboard Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
services:
postgres:
restart: always
image: "postgres:15"
ports:
- "5432"
environment:
POSTGRES_DB: thingsboard_mqtt_broker
POSTGRES_PASSWORD: postgres
volumes:
- tbmq-postgres-data:/var/lib/postgresql/data
kafka:
restart: always
image: "bitnamilegacy/kafka:3.5.1"
ports:
- "9092"
environment:
KAFKA_CFG_NODE_ID: 0
KAFKA_CFG_PROCESS_ROLES: controller,broker
KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: 0@kafka:9093
KAFKA_CFG_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093
KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://:9092
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER
KAFKA_CFG_INTER_BROKER_LISTENER_NAME: PLAINTEXT
volumes:
- tbmq-kafka-data:/bitnami/kafka
redis:
restart: always
image: "bitnamilegacy/redis:7.0"
environment:
# ALLOW_EMPTY_PASSWORD is recommended only for development.
ALLOW_EMPTY_PASSWORD: "yes"
ports:
- "6379"
volumes:
- tbmq-redis-data:/bitnami/redis/data
tbmq:
restart: always
image: "thingsboard/tbmq:1.4.0"
depends_on:
- postgres
- kafka
- redis
ports:
- "8083:8083"
- "1883:1883"
- "8084:8084"
environment:
TB_SERVICE_ID: tbmq
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/thingsboard_mqtt_broker
SPRING_DATASOURCE_USERNAME: postgres
SPRING_DATASOURCE_PASSWORD: postgres
TB_KAFKA_SERVERS: kafka:9092
REDIS_HOST: redis
SECURITY_MQTT_BASIC_ENABLED: "true"
#JAVA_OPTS: "-Xmx2048M -Xms2048M -Xss384k -XX:+AlwaysPreTouch"
volumes:
- tbmq-logs:/var/log/thingsboard-mqtt-broker
- tbmq-data:/data
volumes:
tbmq-postgres-data:
external: true
tbmq-kafka-data:
external: true
tbmq-redis-data:
external: true
tbmq-logs:
external: true
tbmq-data:
external: true

Create the Redis data volume:

Terminal window
docker volume create tbmq-redis-data

Then run the script to apply the changes:

Terminal window
./tbmq-install-and-run.sh

Afterward, proceed with the upgrade.

  1. Go to your installation directory.

    Run the upgrade from the directory that contains docker-compose.yml and .tbmq-upgrade.env.

  2. Download the upgrade script.

    Terminal window
    wget -O tbmq-upgrade.sh https://raw.githubusercontent.com/thingsboard/tbmq/release-2.4.2/msa/tbmq/configs/tbmq-upgrade.sh &&
    chmod +x tbmq-upgrade.sh

    The script upgrades TBMQ 2.4.1 to 2.4.2. It changes the tbmq and tbmq-integration-executor image tags in docker-compose.yml, keeping the original as docker-compose.yml.bak, and stops with Failed to replace the image version if the file does not reference TBMQ 2.4.1.

  3. Check the connection settings.

    The script connects to PostgreSQL and Valkey with the default settings from docker-compose.yml. If you changed them, edit the db_url, db_username, db_password, and valkey_url variables at the top of tbmq-upgrade.sh to match before running it.

  4. Run the upgrade.

    Terminal window
    ./tbmq-upgrade.sh

    After the database upgrade, the script asks you to confirm removing the stopped tbmq container (Going to remove …-tbmq-1). Answer y; the script then starts TBMQ on the new version.

    The upgrade script stops the tbmq service while the upgrade runs and starts it again afterwards, so expect a brief interruption.

To enable MQTT over SSL/TLS (MQTTS) in TBMQ, provide valid SSL certificates and configure TBMQ to use them.

For details on supported formats and configuration options, see the MQTT over SSL guide.

  1. Prepare SSL certificates.

    Obtain a valid SSL certificate and private key. For example:

    • mqttserver.pem — public certificate (may include the full chain)
    • mqttserver_key.pem — private key
  2. Mount certificates into the container.

    In your docker-compose.yml, mount the directory containing the certificates into the tbmq service:

    docker-compose.yml
    services:
    tbmq:
    volumes:
    - tbmq-logs:/var/log/thingsboard-mqtt-broker
    - tbmq-data:/data
    - PATH_TO_CERTS:/config/certificates

    Replace PATH_TO_CERTS with the path to your certificate files.

  3. Let TBMQ read the certificate files.

    TBMQ runs as the thingsboard user (UID 799) inside the container and must be able to read both files. Private keys are usually readable only by their owner, so give that user ownership of the files:

    Terminal window
    sudo chown 799:799 PATH_TO_CERTS/mqttserver.pem PATH_TO_CERTS/mqttserver_key.pem

    If TBMQ cannot read a file, it fails to start and logs Permission denied for that file.

  4. Configure environment variables.

    Add the following variables to the tbmq service environment in docker-compose.yml:

    docker-compose.yml
    LISTENER_SSL_ENABLED: "true"
    LISTENER_SSL_PEM_CERT: "/config/certificates/mqttserver.pem"
    LISTENER_SSL_PEM_KEY: "/config/certificates/mqttserver_key.pem"
    LISTENER_SSL_PEM_KEY_PASSWORD: "server_key_password"

    Leave LISTENER_SSL_PEM_KEY_PASSWORD empty if your private key is not password-protected.

  5. Expose the MQTTS port.

    In docker-compose.yml, add the port to the tbmq service:

    docker-compose.yml
    services:
    tbmq:
    ports:
    - "8083:8083"
    - "1883:1883"
    - "8084:8084"
    - "8883:8883"
  6. Restart TBMQ.

    Terminal window
    ./tbmq-install-and-run.sh

    Once restarted, MQTT clients can securely connect to port 8883 using TLS/SSL.

Connect your first client

Set up client credentials, then publish and subscribe with an MQTT client. See Getting started.

Secure the broker

Choose the authentication provider that fits your clients. See Security overview.

Watch the broker

Track sessions, throughput, and resource usage as traffic grows. See Monitoring.