Docker on Ubuntu Installation - tirta-ir/kalbe-b7-sealing-temp GitHub Wiki

This guide will help you to install and start ThingsBoard and Trendz using docker on linux or Mac OS. You'll need to install Docker first using these guide:

Installing ThingsBoard CE using Docker

Step 1. Choose the docker images

Depending on the database used there are three type of ThingsBoard single instance docker images:

  • thingsboard/tb-postgres - single instance of ThingsBoard with PostgreSQL database. Recommended option for small servers with at least 1GB of RAM and minimum load (few messages per second). 2-4GB is recommended.

  • thingsboard/tb-cassandra - single instance of ThingsBoard with Cassandra database. The most performant and recommended option but requires at least 4GB of RAM. 8GB is recommended.

  • thingsboard/tb - single instance of ThingsBoard with embedded HSQLDB database. Note: Not recommended for any evaluation or production usage and is used only for development purposes and automatic tests.

In this instruction thingsboard/tb-postgres image will be used. You can choose any other images with different databases (see above).

Step 2. Choose ThingsBoard queue service

Please refer to the previous installation step 4.

Step 3. Compile docker-compose.yml

Create docker compose file for ThingsBoard queue service using sudo nano docker-compose.yml and add the following lines to the yml file:

version: '3.0'
services:
  mytb:
    restart: always
    image: "thingsboard/tb-postgres"
    ports:
      - "8080:9090"
      - "1883:1883"
      - "7070:7070"
      - "5683-5688:5683-5688/udp"
    environment:
      TB_QUEUE_TYPE: in-memory
    volumes:
      - ~/.mytb-data:/data
      - ~/.mytb-logs:/var/log/thingsboard

Before starting your Docker containers, execute the following commands to create directories for data storage and logs. These commands will also change the ownership of the newly created directories to the Docker container user.

The chown command is used to change the owner of the directories, and it requires sudo permissions. You may be prompted to enter a password to grant sudo access:

mkdir -p ~/.mytb-data && sudo chown -R 799:799 ~/.mytb-data
mkdir -p ~/.mytb-logs && sudo chown -R 799:799 ~/.mytb-logs

NOTE: Replace directory ~/.mytb-data and ~/.mytb-logs with directories you’re planning to use in docker-compose.yml.

Set the terminal in the directory which contains the docker-compose.yml file and execute the following commands to up this docker compose directly:

# Upload the container to docker
docker compose up -d

# See the container logs
docker compose logs -f mytb

After executing this command please refer to this guide to access the web and login credentials

Step 4. Detaching, stop, and start commands

Use these commands to start, stop, and restart the container:

# Start the container
docker compose start mytb

# Stop the container
docker compose stop mytb

# Restart the container
docker compose restart mytb

Step 5. Upgrade ThingsBoard

In order to update to the latest image, execute the following commands:

docker pull thingsboard/tb-postgres
docker compose stop
docker run -it -v ~/.mytb-data:/data --rm thingsboard/tb-postgres upgrade-tb.sh
docker compose rm mytb
docker compose up

Installing Trendz using Docker

Step 1. Obtain the license key

We assume you have already chosen subscription plan for Trendz and have license key. If not, please get your Free Trial license before you proceed. See How-to get pay-as-you-go subscription for more details.

Note: We will reference the license key you have obtained during this step as PUT_YOUR_LICENSE_SECRET_HERE later in this guide.

Step 2. Running Trendz service

Create docker compose file for Trendz Analytics service using sudo nano docker-compose.yml and add the following line to the yml file. Don't forget to replace the license from the first step.

version: '3.0'
services:
  mytrendz:
    restart: always
    image: "thingsboard/trendz:1.10.3-HF3"
    ports:
      - "8888:8888"
    environment:
      TB_API_URL: http://localhost:8080
      TRENDZ_LICENSE_SECRET: PUT_YOUR_LICENSE_SECRET_HERE
      TRENDZ_LICENSE_INSTANCE_DATA_FILE: /data/license.data
      SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/trendz
      SPRING_DATASOURCE_USERNAME: postgres
      SPRING_DATASOURCE_PASSWORD: postgres
      SCRIPT_ENGINE_PROVIDER: DOCKER_CONTAINER
      SCRIPT_ENGINE_DOCKER_PROVIDER_URL: mypyexecutor:8080
      SCRIPT_ENGINE_TIMEOUT: 30000
    volumes:
      - ~/.mytrendz-data:/data
      - ~/.mytrendz-logs:/var/log/trendz
  mypyexecutor:
    restart: always
    image: "thingsboard/trendz-python-executor:1.10.3"
    ports:
      - "8080"
    environment:
      MAX_HEAP_SIZE: 750M
      SCRIPT_ENGINE_RUNTIME_TIMEOUT: 30000
      EXECUTOR_MANAGER: 1
      EXECUTOR_SCRIPT_ENGINE: 6
      THROTTLING_QUEUE_CAPACITY: 10
      THROTTLING_THREAD_POOL_SIZE: 6
      NETWORK_BUFFER_SIZE: 5242880
  postgres:
    restart: always
    image: "postgres:15"
    ports:
      - "5432"
    environment:
      POSTGRES_DB: trendz
      POSTGRES_PASSWORD: postgres
    volumes:
      - ~/.mytrendz-data/db:/var/lib/postgresql/data

Run following commands, before starting docker container(s), to create folders for storing data and logs. These commands additionally will change owner of newly created folders to docker container user. To do this (to change user) chown command is used, and this command requires sudo permissions (command will request password for a sudo access):

sudo mkdir -p ~/.mytrendz-data && sudo chown -R 799:799 ~/.mytrendz-data
sudo mkdir -p ~/.mytrendz-logs && sudo chown -R 799:799 ~/.mytrendz-logs

Step 3. Running the container

Set the terminal in the directory which contains the docker-compose.yml file and execute docker compose up -d.

After executing this command you can open http://{your-host-ip}:8888 in you browser (for ex. http://localhost:8888). You should see Trendz login page.

For first authentication you need to use Tenant Administrator credentials from your ThingsBoard

Trendz uses ThingsBoard as an authentication service. During first sign in ThingsBoard service should be also available to validate credentials.

You can refer to this section to stop, start, or restart the container just like in ThingsBoard method.