Linux本地部署TeslaMate结合内网穿透实现公网访问内网车辆信息-1. Docker部署TeslaMate

时间:2024-03-28 12:51:29

在Linux中任意目录下创建一个docker-compose.yml文件

vim docker-compose.yml

然后把以下内容复制进去,其中注释的地方需要自行修改一下

version: "3"

services:
  teslamate:
    image: teslamate/teslamate:latest
    restart: always
    environment:
      - ENCRYPTION_KEY=secretkey #自定义设置一个加密的kay
      - DATABASE_USER=teslamate
      - DATABASE_PASS=password #自定义设置一个密码!
      - DATABASE_NAME=teslamate
      - DATABASE_HOST=database
      - MQTT_HOST=mosquitto
    ports:
      - 4000:4000
    volumes:
      - ./import:/opt/app/import
    cap_drop:
      - all

  database:
    image: postgres:latest
    restart: always
    environment:
      - POSTGRES_USER=teslamate
      - POSTGRES_PASSWORD=password #自定义设置一个密码!
      - POSTGRES_DB=teslamate
    volumes:
      - teslamate-db:/var/lib/postgresql/data

  grafana:
    image: teslamate/grafana:latest
    restart: always
    environment:
      - DATABASE_USER=teslamate
      - DATABASE_PASS=password #自定义设置一个密码!
      - DATABASE_NAME=teslamate
      - DATABASE_HOST=database
    ports:
      - 3000:3000
    volumes:
      - teslamate-grafana-data:/var/lib/grafana

  mosquitto:
    image: eclipse-mosquitto:2
    restart: always
    command: mosquitto -c /mosquitto-no-auth.conf
    volumes:
      - mosquitto-conf:/mosquitto/config
      - mosquitto-data:/mosquitto/data

volumes:
  teslamate-db:
  teslamate-grafana-data:
  mosquitto-conf:
  mosquitto-data:

然后保存文件,执行下面命令部署启动

docker compose up -d

启动部署完成后,界面正常可以看到每个镜像容器都已经正常安装和创建运行,执行docker ps 可以看到成功运行了teslamate容器,接下来进行本地访问

image-20240104105132740