背景:これまで適当にdockerを入れていた。手順確認のためDocker社の推奨手順で入れる
詳細:
OSバージョン確認 ( Version 12 / book worm)
$ cat /etc/os-release PRETTY_NAME="Debian GNU/Linux 12 (bookworm)" NAME="Debian GNU/Linux" VERSION_ID="12" VERSION="12 (bookworm)" VERSION_CODENAME=bookworm ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/"
インストール済みのパッケージ類を最新化
sudo apt update sudo apt upgrade -y
必要なパッケージをインストール
sudo apt install -y ca-certificates curl
Docker公式リポジトリからダウンロードするために鍵を入手
sudo mkdir -p /etc/apt/keyrings sudo chmod 0755 /etc/apt/keyrings sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc sudo chmod a+r /etc/apt/keyrings/docker.asc
鍵は/etc/apt/keyrings/docker.ascに置かれる
#Docker社の公式リポジトリを追加
echo \ "deb [arch=$(dpkg --print-architecture) \ signed-by=/etc/apt/keyrings/docker.asc] \ https://download.docker.com/linux/debian \ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt update
Docker社の公式リポジトリからdockerパッケージをインストール
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
動作確認(Hello worldコンテナを起動)
sudo docker run hello-world
sudoなしに一般権限でDockerを使えるように 現在ログインしているユーザ($USER)をdockerグループに追加
sudo usermod -aG docker $USER
上記手順で一般権限からDockerが使えるようになる
インストールされた Docker version
$ docker -v Docker version 28.1.1, build 4eba377
■追記
つづいてThingBoardを入れる
使うdocker-compose.ymlは以下
file: docker-compose.yml
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
永続化のためのディレクトリを設定
mkdir -p ~/.mytb-data && sudo chown -R 799:799 ~/.mytb-data mkdir -p ~/.mytb-logs && sudo chown -R 799:799 ~/.mytb-logs
docker composeでビルド、実行する
docker compose up -d docker compose logs -f mytb
かなり待ってログイン画面が出る*1
ID/PWDはThingBoardのサイトに書かれているのを使う。以下のWebPageに、テナント管理者権限でログインするためのID/PWDが書かれているのでこれを使う。
Getting Started with ThingsBoard | ThingsBoard Community Edition
テナント管理者権限で入った画面
コンテナ内のプロセス
thingsboard@11b69cdde87c:/$ ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND thingsb+ 1 0.0 0.0 4332 2984 ? Ss 07:14 0:00 /bin/bash /usr/bin/start-tb.sh thingsb+ 30 0.0 0.3 217256 27660 ? Ss 07:14 0:00 /usr/lib/postgresql/12/bin/postgres thingsb+ 32 0.0 0.6 217516 52820 ? Ss 07:14 0:00 postgres: checkpointer thingsb+ 33 0.0 0.0 217256 7972 ? Ss 07:14 0:00 postgres: background writer thingsb+ 34 0.0 0.1 217256 10036 ? Ss 07:14 0:00 postgres: walwriter thingsb+ 35 0.0 0.1 217824 8456 ? Ss 07:14 0:00 postgres: autovacuum launcher thingsb+ 36 0.0 0.0 71756 5632 ? Ss 07:14 0:00 postgres: stats collector thingsb+ 37 0.0 0.0 217676 7660 ? Ss 07:14 0:00 postgres: logical replication launcher thingsb+ 194 33.5 13.5 6367048 1082632 ? Sl 07:18 13:29 java -cp /usr/share/thingsboard/bin/thingsboard.jar -Dplatform=deb -Dinstall.data_dir=/usr/share/thingsboard/data -X thingsb+ 620 0.0 0.2 220236 20044 ? Ss 07:48 0:00 postgres: thingsboard thingsboard 127.0.0.1(57806) idle thingsb+ 621 0.0 0.2 218332 16344 ? Ss 07:48 0:00 postgres: thingsboard thingsboard 127.0.0.1(47596) idle thingsb+ 622 0.0 0.1 218204 12428 ? Ss 07:48 0:00 postgres: thingsboard thingsboard 127.0.0.1(47606) idle thingsb+ 623 0.0 0.1 218204 12428 ? Ss 07:49 0:00 postgres: thingsboard thingsboard 127.0.0.1(47622) idle thingsb+ 624 0.0 0.1 218204 12428 ? Ss 07:49 0:00 postgres: thingsboard thingsboard 127.0.0.1(36786) idle thingsb+ 625 0.0 0.1 218204 12428 ? Ss 07:49 0:00 postgres: thingsboard thingsboard 127.0.0.1(36794) idle thingsb+ 626 0.0 0.1 218204 12428 ? Ss 07:49 0:00 postgres: thingsboard thingsboard 127.0.0.1(36806) idle thingsb+ 630 0.0 0.1 218204 12428 ? Ss 07:49 0:00 postgres: thingsboard thingsboard 127.0.0.1(43468) idle thingsb+ 631 0.0 0.1 218204 12428 ? Ss 07:49 0:00 postgres: thingsboard thingsboard 127.0.0.1(43470) idle thingsb+ 632 0.0 0.1 218204 12428 ? Ss 07:49 0:00 postgres: thingsboard thingsboard 127.0.0.1(43484) idle thingsb+ 633 0.0 0.1 218204 12428 ? Ss 07:49 0:00 postgres: thingsboard thingsboard 127.0.0.1(43500) idle thingsb+ 634 0.0 0.1 218204 12428 ? Ss 07:49 0:00 postgres: thingsboard thingsboard 127.0.0.1(57840) idle thingsb+ 635 0.0 0.1 218204 12428 ? Ss 07:49 0:00 postgres: thingsboard thingsboard 127.0.0.1(57852) idle thingsb+ 636 0.0 0.1 218204 12428 ? Ss 07:49 0:00 postgres: thingsboard thingsboard 127.0.0.1(57860) idle thingsb+ 637 0.0 0.1 218204 12428 ? Ss 07:49 0:00 postgres: thingsboard thingsboard 127.0.0.1(57862) idle thingsb+ 638 0.0 0.1 218204 12428 ? Ss 07:49 0:00 postgres: thingsboard thingsboard 127.0.0.1(57876) idle thingsb+ 668 0.2 0.0 4480 3416 pts/0 Ss 07:58 0:00 /bin/bash thingsb+ 677 100 0.0 8444 4020 pts/0 R+ 07:58 0:00 ps aux thingsboard@11b69cdde87c:/$ id uid=799(thingsboard) gid=799(thingsboard) groups=799(thingsboard)
thingsboard:x:799:799:Thingsboard application,,,:/home/thingsboard:/usr/sbin/nologin postgres:x:100:102:PostgreSQL administrator,,,:/var/lib/postgresql:/bin/bash
コンテナ内のListen状況
thingsboard@11b69cdde87c:/var/log/thingsboard$ ./netstat -na |grep -i listen tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN tcp 0 0 127.0.0.11:38427 0.0.0.0:* LISTEN tcp6 0 0 :::7070 :::* LISTEN tcp6 0 0 :::1883 :::* LISTEN tcp6 0 0 ::1:5432 :::* LISTEN tcp6 0 0 :::9090 :::* LISTEN unix 2 [ ACC ] STREAM LISTENING 12204 /var/run/postgresql/.s.PGSQL.5432
■関連URL
Debian | Docker Docs
Installing ThingsBoard using Docker (Linux or Mac OS) | ThingsBoard Community Edition
*1:若干放置したが11ぐらいかかったかと