Skip to content
Stand with Ukraine flag

Docker Compose

This guide covers setting up TBMQ in cluster mode using Docker Compose.

Terminal window
git clone -b release-2.3.0 https://github.com/thingsboard/tbmq.git
cd tbmq/docker

Create the necessary Docker volumes and update the HAProxy config in the created volume:

Terminal window
./scripts/docker-create-volumes.sh

Run the installation:

Terminal window
./scripts/docker-install-tbmq.sh

Start all services:

Terminal window
./scripts/docker-start-services.sh

Once all services have started, open http://{your-host-ip} in your browser (e.g. http://localhost) and connect MQTT clients on port 1883.

You should see the TBMQ login page. Use the default System Administrator credentials:

Username:

Password:

sysadmin

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

To view TBMQ node logs:

Terminal window
docker compose logs -f tbmq1

To view the state of all containers:

Terminal window
docker compose ps

To inspect logs of all running services:

Terminal window
docker compose logs -f

See the docker compose logs reference for more details.

To stop services:

Terminal window
./scripts/docker-stop-services.sh

To stop and completely remove deployed containers:

Terminal window
./scripts/docker-remove-services.sh

To remove Docker volumes for all containers (warning: deletes all data):

Terminal window
./scripts/docker-remove-volumes.sh

To apply config changes at runtime (e.g. edits to haproxy.cfg or logback.xml):

Terminal window
./scripts/docker-refresh-config.sh

To reload HAProxy configuration without restarting the container, send a HUP signal:

Terminal window
docker exec -it haproxy-certbot sh -c "kill -HUP 1"
  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 commands.

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.

If there are no version-specific notes for your upgrade path, skip directly to Run upgrade.

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

This release migrates all third-party components from Bitnami images to official open-source alternatives. Review the third-party component updates for full details.

Then proceed with the upgrade.

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

The upgrade script reads from the tbmq.env file. Environment variables in docker-compose.yml are not applied during the upgrade — only the values in tbmq.env are used. Make sure this file reflects your active configuration.

Supported variables in tbmq.env

  • 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 verified, proceed with the upgrade.

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

Add Integration Executor microservice

This release adds support for external integrations via the new Integration Executor microservice ( full example).

Pull the updates from the release branch by following the Run upgrade steps up to (but not including) the upgrade script. Then create the required Docker volumes:

Terminal window
./scripts/docker-create-volumes.sh

You should see output similar to:

user@user:~/tbmq/docker$ ./scripts/docker-create-volumes.sh
tbmq-ie1-logs
tbmq-ie2-logs
tbmq-ie-config

Update third-party services

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

ServicePrevious versionUpdated version
Redis7.07.2.5
PostgreSQL15.x16.x
Kafka3.5.13.7.0

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

Pull the latest changes from the release branch:

Terminal window
git pull origin release-2.3.0

Note: Make sure any custom changes are not lost during the merge. Also ensure TBMQ_VERSION in the .env file is set to the target version (e.g. 2.3.0 for the latest).

After pulling, execute the upgrade commands:

Terminal window
./scripts/docker-stop-services.sh
./scripts/docker-upgrade-tbmq.sh
./scripts/docker-start-services.sh

HAProxy handles traffic proxying and serves the web UI on ports 80 and 443 by default. To enable HTTPS with a valid certificate, run:

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

MQTTS allows clients to connect over an encrypted TLS/SSL channel. There are two common approaches:

  • Two-way MQTTS (Mutual TLS) — TBMQ terminates TLS; clients must present valid certificates.
  • One-way MQTTS (TLS termination at load balancer) — HAProxy handles TLS termination and forwards plain MQTT to TBMQ over the internal network.

Both approaches encrypt external connections. Two-way MQTTS adds client certificate verification for higher security; one-way MQTTS simplifies broker configuration and can reuse existing HTTPS certificates.

In this configuration, TBMQ handles TLS termination and (optionally) client certificate authentication directly. This approach is suitable when you want the broker to fully control SSL/TLS and mutual authentication without relying on a load balancer for security.

For supported certificate formats and options, see the MQTT over SSL guide.

Provide SSL certificates

Obtain a valid SSL certificate and private key:

  • mqttserver.pem — public certificate (may include the full chain)
  • mqttserver_key.pem — private key

Mount certificates into the container

In docker-compose.yml, uncomment and update the volume mount:

volumes:
- PATH_TO_CERTS:/config/certificates

Replace PATH_TO_CERTS with the path to your certificate files. Ensure TBMQ has read access.

Configure environment variables

Edit the tbmq.env file and uncomment/configure the following lines:

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 has no password.

Restart services

Terminal window
./scripts/docker-start-services.sh

Once restarted, MQTT clients can connect securely on port 8883.

TLS is terminated at HAProxy. Clients connect to HAProxy on port 8883, which forwards plain MQTT to TBMQ on port 1883. You can reuse the same certificate used for HTTPS.

Point HAProxy to your certificate bundle (PEM with full chain + private key). If you reuse the HTTPS certificate, reference the same bundle. Update the haproxy.cfg file:

listen mqtts-in
bind *:${MQTTS_PORT} ssl crt /usr/local/etc/haproxy/certs.d/fullchain-and-key.pem
mode tcp
option clitcpka # For TCP keep-alive
timeout client 3h
timeout server 3h
option tcplog
balance leastconn
server tbMqtt1 tbmq1:1883 check inter 5s resolvers docker_resolver resolve-prefer ipv4
server tbMqtt2 tbmq2:1883 check inter 5s resolvers docker_resolver resolve-prefer ipv4

Replace fullchain-and-key.pem with the actual filename of your certificate bundle.