website/docs/installation/docker.md
This document provides the necessary steps for installation of TeslaMate on any system that runs Docker. You run NixOS? We got you covered, see NixOS install.
This setup is recommended only if you are running TeslaMate on your home network, as otherwise your Tesla API tokens might be at risk. If you intend to access TeslaMate from the Internet, the recommended way is to use a secure connection (such as a VPN, Cloudflare Tunnel, Tailscale, Zero Tier and a reverse proxy for portless access) for secured access to your TeslaMate instance outside your home network. Alternatively, you can use a reverse proxy (such as Traefik, Apache2 or Caddy) with appropriate hardening to secure your TeslaMate instance before expose it to the internet, check out the advanced guides with Traefik for an example how to use Traefik with TeslaMate. Or you can use the advanced guides with Apache to set up TeslaMate with Apache2, TLS and HTTP Basic Auth.
Create a file called docker-compose.yml with the following content:
services:
teslamate:
image: teslamate/teslamate:latest
restart: always
environment:
- ENCRYPTION_KEY=secretkey #replace with a secure key to encrypt your Tesla API tokens
- DATABASE_USER=teslamate
- DATABASE_PASS=password #insert your secure database password!
- DATABASE_NAME=teslamate
- DATABASE_HOST=database
- MQTT_HOST=mosquitto
ports:
- 4000:4000
volumes:
- ./import:/opt/app/import
cap_drop:
- all
database:
image: postgres:18-trixie
restart: always
environment:
- POSTGRES_USER=teslamate
- POSTGRES_PASSWORD=password #insert your secure database password!
- POSTGRES_DB=teslamate
volumes:
- teslamate-db:/var/lib/postgresql
grafana:
image: teslamate/grafana:latest
restart: always
environment:
- DATABASE_USER=teslamate
- DATABASE_PASS=password #insert your secure database 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
# ports:
# - 1883:1883
volumes:
- mosquitto-conf:/mosquitto/config
- mosquitto-data:/mosquitto/data
volumes:
teslamate-db:
teslamate-grafana-data:
mosquitto-conf:
mosquitto-data:
Choose a secure encryption key that will be used to encrypt your Tesla API tokens (insert as ENCRYPTION_KEY).
Choose your secure database password and insert it at every occurrence of DATABASE_PASS and POSTGRES_PASSWORD
Start the docker containers with docker compose up. To run the containers in the background add the -d flag:
docker compose up -d
If you have a MCU2 upgraded car, you can replace image: teslamate/teslamate:latest with image: ghcr.io/teslamate-org/teslamate:pr-4453 to get the latest version of TeslaMate that supports MCU2 upgraded cars (improved sleeping behavior for MCU2 upgraded cars).
admin (initial password admin) and enter a secure password.To update the running TeslaMate configuration to the latest version, follow: Upgrading to a new version