本指南将帮助您在Linux或Mac OS上使用Docker安装和启动ThingsBoard网关。

先决条件

  • 安装Docker CE

    运行

    执行以下命令以直接运行此docker:
    1. docker run -it -v ~/.tb-gateway/logs:/thingsboard_gateway/logs -v ~/.tb-gateway/extensions:/thingsboard_gateway/extensions -v ~/.tb-gateway/config:/thingsboard_gateway/config --name tb-gateway --restart always thingsboard/tb-gateway

说明:
«««< HEAD

  • docker run - 运行容器
  • -it - 将终端会话与网关进程输出连接
  • -v ~/.tb-gateway/config:/etc/thingsboard-gateway/config - 挂载主机目录~/.tb-gateway/config至网关配置目录
  • -v ~/.tb-gateway/extensions:/var/lib/thingsboard_gateway/extensions - 挂载主机目录~/.tb-gateway/extensions至网关扩展目录
  • -v ~/.tb-gateway/logs:/var/log/thingsboard-gateway - 挂载主机目录~/.tb-gateway/logs至网关日志目录
  • --name tb-gateway - 网关在本机的别名
  • --restart always - 系统重启或出现故障后自动启动ThingsBoard。
  • thingsboard/tb-gateway - docker镜像
  • docker run - run this container
  • -it - attach a terminal session with current Gateway process output
  • -v ~/.tb-gateway/config:/thingsboard_gateway/config - mounts the host’s dir ~/.tb-gateway/config to Gateway config directory
  • -v ~/.tb-gateway/extensions:/thingsboard_gateway/extensions - mounts the host’s dir ~/.tb-gateway/extensions to Gateway extensions directory
  • -v ~/.tb-gateway/logs:/thingsboard_gateway/logs - mounts the host’s dir ~/.tb-gateway/logs to Gateway logs directory
  • --name tb-gateway - friendly local name of this machine
  • --restart always - automatically start ThingsBoard in case of system reboot and restart in case of failure.
  • thingsboard/tb-gateway - docker image

    master

分离、停止和启动

您可以使用Ctrl-p Ctrl-q - 与会话终端分离-容器将继续在后台运行.
要重新连接到终端(查看网关日志),请运行:
分离容器:

  1. docker attach tb-gateway

停止容器:

  1. docker stop tb-gateway

启动容器:

  1. docker start tb-gateway

网关配置

停止容器:

  1. docker stop tb-gateway

使用本指南将网关配置为与ThingsBoard实例一起使用:
进行更改后启动容器:

  1. docker start tb-gateway

升级

为了更新到最新的镜像,请执行以下命令:

  1. $ docker pull thingsboard/tb-gateway
  2. $ docker stop tb-gateway
  3. $ docker rm tb-gateway
  4. $ docker run -it -v ~/.tb-gateway/logs:/var/log/thingsboard-gateway -v ~/.tb-gateway/extensions:/var/lib/thingsboard_gateway/extensions -v ~/.tb-gateway/config:/etc/thingsboard-gateway/config --name tb-gateway --restart always thingsboard/tb-gateway