when using Livekit-docker (Self Hosted) how do you...
# ask-ai
h
when using Livekit-docker (Self Hosted) how do you save the configuration so it survives a reset of the docker containers status
t
Thanks for reaching out, Cameron. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking how to make your LiveKit self‑hosted Docker configuration survive container resets — here’s how to persist it. • Store config files on the host and bind‑mount them into containers. The installer places configs under /opt/livekit; keep those files (e.g.,
livekit.yaml
,
docker-compose.yaml
,
caddy.yaml
) on the host and mount them in your Compose services. • Use Docker volumes for stateful data (example for Caddy TLS and other runtime state):
Copy code
services:
    livekit-caddy:
      volumes:
        - ./caddy.yaml:/etc/caddy/Caddyfile
        - caddy_data:/data
    livekit-server:
      volumes:
        - ./livekit.yaml:/etc/livekit/livekit.yaml
  volumes:
    caddy_data:
• If you use the provided systemd service (
livekit-docker
), it will start the Compose stack using the host configs in
/opt/livekit
. Restarting the service or recreating containers will keep your configuration as long as the host files and volumes remain intact. If you want, tell me: • Where your current config files live (default
/opt/livekit
or elsewhere), and • Whether you need sample Compose volume entries for any other services (Redis, Postgres, etc.). Sources: Deploy to a VM | LiveKit docs
h
I am wanting to save the SIP trunk, dispatch rules, agent setups
t
You're asking how to persist SIP trunks, dispatch rules, and agent setups so they survive Docker container resets. A few quick questions, then actionable steps. Questions • Where are you currently managing these settings: LiveKit UI, CLI/API, or stored in files? • Which state store are you using (embedded, Redis, or another DB)? • Are you using the installer defaults (configs under /opt/livekit) or a custom compose layout? What to do (actions you can take now) 1. Persist the state store ◦ If SIP trunks and dispatch rules are stored in Redis or another external store, mount that store to persistent storage (Docker volume or host bind). Example in compose:
Copy code
services:
       redis:
         volumes:
           - redis_data:/data
     volumes:
       redis_data:
• Confirm your LiveKit server is pointed to that persistent Redis instance. 1. Persist config files and agent deployments ◦ Keep
livekit.yaml
,
livekit.toml
, agent Dockerfiles/code, and any generated config files on the host (default
/opt/livekit
) and bind‑mount them into containers so edits survive container recreation. ◦ Example mount:
Copy code
services:
       livekit-server:
         volumes:
           - ./livekit.yaml:/etc/livekit/livekit.yaml
           - ./livekit.toml:/etc/livekit/livekit.toml
1. Persist secrets and environment settings ◦ Store secrets and env vars outside the container (env files, secret mounts) rather than baked into images. ◦ Use the secrets pattern or host files so restarts reuse the same credentials. 1. Version control and backups ◦ Keep agent code,
livekit.toml
, and dispatch/SIP configs in a git repo. ◦ Periodically export or back up your Redis/state store so you can restore rules and agent metadata if needed. If you tell me where your settings are currently stored (answers to the questions above), I’ll give exact docker-compose volume entries and any API/CLI commands to export/import those SIP trunks, dispatch rules, and agent configs. Would you like that? Sources: Distributed Setup | LiveKit docs | Deploy to a VM | LiveKit docs | Builds and Dockerfiles | LiveKit Docs | Secrets management | LiveKit docs | Deploying to production | LiveKit Docs
h
I am currently configuring them with the LiveKit CLI so i do not know how Livekit stores the config.
t
You're configuring via the LiveKit CLI — good to know. Here’s how those CLI-created settings are stored and how to make them survive container resets. How CLI configs are persisted • SIP trunks, dispatch rules, and agent metadata are stored in LiveKit’s state store (typically Redis or another external DB), not inside ephemeral containers. • Agent deployment definitions (e.g.,
livekit.toml
) and any local files you use to build agents should be kept on the host and version‑controlled. What you should do to persist them 1. Ensure the state store is persistent ◦ If you use Redis, mount Redis data to a Docker volume or host path so Redis data survives container recreation:
Copy code
services:
       redis:
         volumes:
           - redis_data:/data
     volumes:
       redis_data:
• Confirm the LiveKit server is configured to point to that Redis instance. 1. Persist CLI-managed files and agent code ◦ Store
livekit.toml
, agent Dockerfiles, and any local config files on the host (default installer location is
/opt/livekit
) and bind‑mount them into containers:
Copy code
services:
       livekit-server:
         volumes:
           - ./livekit.yaml:/etc/livekit/livekit.yaml
           - ./livekit.toml:/etc/livekit/livekit.toml
1. Store secrets and env vars externally ◦ Keep API keys and secrets in env files or secret mounts rather than baking them into images so restarts reuse the same credentials. 1. Backup and version control ◦ Commit agent code and config files to git and periodically back up your Redis/data volume so you can restore CLI-created rules if needed. Quick clarifying question • Which state store is your LiveKit server using right now (embedded, Redis, or another DB)? With that I can give exact docker-compose volume entries and a simple backup/restore command for your setup.
h
looking at the docker-compose.yaml this is the current config for both livekit and redis:
Copy code
# This docker-compose requires host networking, which is only available on Linux
# This compose will not function correctly on Mac or Windows
services:
  caddy:
    image: livekit/caddyl4
    command: run --config /etc/caddy.yaml --adapter yaml
    restart: unless-stopped
    network_mode: "host"
    volumes:
      - ./caddy.yaml:/etc/caddy.yaml
      - ./caddy_data:/data
  livekit:
    image: livekit/livekit-server:latest
    command: --config /etc/livekit.yaml
    restart: unless-stopped
    network_mode: "host"
    volumes:
      - ./livekit.yaml:/etc/livekit.yaml
  redis:
    image: redis:7-alpine
    command: redis-server /etc/redis.conf
    restart: unless-stopped
    network_mode: "host"
    volumes:
      - ./redis.conf:/etc/redis.conf
  egress:
    image: livekit/egress:latest
    restart: unless-stopped
    environment:
      - EGRESS_CONFIG_FILE=/etc/egress.yaml
    network_mode: "host"
    volumes:
      - ./egress.yaml:/etc/egress.yaml
    cap_add:
      - CAP_SYS_ADMIN
  ingress:
    image: livekit/ingress:latest
    restart: unless-stopped
    environment:
      - INGRESS_CONFIG_FILE=/etc/ingress.yaml
    network_mode: "host"
    volumes:
      - ./ingress.yaml:/etc/ingress.yaml
  sip:
    image: livekit/sip
    network_mode: host
    restart: unless-stopped
    environment:
      SIP_CONFIG_BODY: |
        api_key: 'key_goes_here'
        api_secret: 'secret_goes_here'
        ws_url: 'ws://127.0.0.1:7880'
        redis:
          address: 'localhost:6379'
        sip_port: 5060
        rtp_port_range_start: 10000
        rtp_port_range_end: 20000
        local_ip: '::'
        logging:
          level: debug
t
Thanks — with your compose file I can give concrete, minimal changes to ensure CLI-created SIP trunks, dispatch rules, and agent metadata persist. Summary of what to change • LiveKit CLI writes state to Redis. Persist Redis data to survive container recreation. • Move SIP config out of the environment block into a mounted file so it’s versionable and backed up. • Keep your existing mounted YAMLs (livekit.yaml, egress.yaml, ingress.yaml) as-is. Suggested docker-compose edits 1) Persist Redis data (add a data volume)
Copy code
redis:
  image: redis:7-alpine
  command: redis-server /etc/redis.conf
  restart: unless-stopped
  network_mode: "host"
  volumes:
    - ./redis.conf:/etc/redis.conf
    - redis_data:/data
...
volumes:
  redis_data:
  caddy_data:
2) Move SIP config to a file (create
sip.yaml
next to your compose)
Copy code
sip:
  image: livekit/sip
  network_mode: host
  restart: unless-stopped
  environment:
    SIP_CONFIG_FILE: /etc/sip.yaml
  volumes:
    - ./sip.yaml:/etc/sip.yaml
Example sip.yaml (based on your current env block)
Copy code
api_key: 'key_goes_here'
api_secret: 'secret_goes_here'
ws_url: 'ws://127.0.0.1:7880'
redis:
  address: 'localhost:6379'
sip_port: 5060
rtp_port_range_start: 10000
rtp_port_range_end: 20000
local_ip: '::'
logging:
  level: debug
3) Enable Redis persistence in redis.conf (if not already) Ensure
redis.conf
contains RDB/AOF persistence lines, e.g.:
Copy code
save 900 1
save 300 10
save 60 10000
appendonly yes
appendfilename "appendonly.aof"
dir /data
Backup and restore notes (brief) • Backup: periodically copy the volume (named
redis_data
) or use Redis BGSAVE and copy the RDB/AOF files from the host path. • Restore: stop containers, restore RDB/AOF into the volume, then start containers. If you want, I can: • Provide exact commands to back up and restore the Redis volume on your host, or • Show a minimal
docker-compose
full file with these changes incorporated. Which would you prefer? Sources: SIP APIs | LiveKit docs | Agents Framework | livekit/livekit_composite | DeepWiki | Distributed Setup | LiveKit docs | Deploying LiveKit | LiveKit docs | Self-hosted SIP server | LiveKit docs
h
provide the full docker-compose based on your changes as it is not clear on the volume layout
t
Below is a complete docker-compose.yaml that incorporates persistent storage for Redis, moves the SIP config to a mounted file, and keeps your other configs mounted. It uses named volumes for Redis and Caddy data and bind‑mounts host YAML files (so keep the files next to the compose file: livekit.yaml, caddy.yaml, redis.conf, egress.yaml, ingress.yaml, sip.yaml). Note: Host networking is preserved as in your original file.
Copy code
version: "3.8"

services:
  caddy:
    image: livekit/caddyl4
    command: run --config /etc/caddy.yaml --adapter yaml
    restart: unless-stopped
    network_mode: "host"
    volumes:
      - ./caddy.yaml:/etc/caddy.yaml
      - caddy_data:/data

  livekit:
    image: livekit/livekit-server:latest
    command: --config /etc/livekit.yaml
    restart: unless-stopped
    network_mode: "host"
    volumes:
      - ./livekit.yaml:/etc/livekit.yaml

  redis:
    image: redis:7-alpine
    command: redis-server /etc/redis.conf
    restart: unless-stopped
    network_mode: "host"
    volumes:
      - ./redis.conf:/etc/redis.conf
      - redis_data:/data

  egress:
    image: livekit/egress:latest
    restart: unless-stopped
    environment:
      - EGRESS_CONFIG_FILE=/etc/egress.yaml
    network_mode: "host"
    volumes:
      - ./egress.yaml:/etc/egress.yaml
    cap_add:
      - CAP_SYS_ADMIN

  ingress:
    image: livekit/ingress:latest
    restart: unless-stopped
    environment:
      - INGRESS_CONFIG_FILE=/etc/ingress.yaml
    network_mode: "host"
    volumes:
      - ./ingress.yaml:/etc/ingress.yaml

  sip:
    image: livekit/sip
    network_mode: host
    restart: unless-stopped
    environment:
      SIP_CONFIG_FILE: /etc/sip.yaml
    volumes:
      - ./sip.yaml:/etc/sip.yaml

volumes:
  redis_data:
  caddy_data:
Quick checklist after applying this compose: • Create a
sip.yaml
next to this file (example content you already provided). • Ensure
redis.conf
enables persistence and sets
dir /data
. • Bring up with
docker-compose up -d
. • Back up the
redis_data
volume regularly (or copy the RDB/AOF files from the host if you map them). Would you like the exact example
sip.yaml
and a short command sequence to back up/restore the Redis volume?
h
yes create the sip.yaml
t
Create a file named sip.yaml next to your docker-compose.yaml with this content (replace keys/URLs/ports as needed):
Copy code
api_key: 'key_goes_here'
api_secret: 'secret_goes_here'
ws_url: 'ws://127.0.0.1:7880'
redis:
  address: 'localhost:6379'
sip_port: 5060
rtp_port_range_start: 10000
rtp_port_range_end: 20000
local_ip: '::'
logging:
  level: debug
Usage notes • Keep this file under version control and back it up. • After creating sip.yaml, run:
docker-compose up -d
to apply. • Ensure
redis.conf
sets
dir /data
and persistence (RDB/AOF) so CLI-created SIP trunks/dispatch rules persist in Redis.
h
ok docker restarted however sip stuck in a restart loop.
Copy code
# This docker-compose requires host networking, which is only available on Linux
# This compose will not function correctly on Mac or Windows
services:
  caddy:
    image: livekit/caddyl4
    command: run --config /etc/caddy.yaml --adapter yaml
    restart: unless-stopped
    network_mode: "host"
    volumes:
      - ./caddy.yaml:/etc/caddy.yaml
      - ./caddy_data:/data
  livekit:
    image: livekit/livekit-server:latest
    command: --config /etc/livekit.yaml
    restart: unless-stopped
    network_mode: "host"
    volumes:
      - ./livekit.yaml:/etc/livekit.yaml
  redis:
    image: redis:7-alpine
    command: redis-server /etc/redis.conf
    restart: unless-stopped
    network_mode: "host"
    volumes:
      - ./redis.conf:/etc/redis.conf
      - redis_data:/data
  egress:
    image: livekit/egress:latest
    restart: unless-stopped
    environment:
      - EGRESS_CONFIG_FILE=/etc/egress.yaml
    network_mode: "host"
    volumes:
      - ./egress.yaml:/etc/egress.yaml
    cap_add:
      - CAP_SYS_ADMIN
  ingress:
    image: livekit/ingress:latest
    restart: unless-stopped
    environment:
      - INGRESS_CONFIG_FILE=/etc/ingress.yaml
    network_mode: "host"
    volumes:
      - ./ingress.yaml:/etc/ingress.yaml
  sip:
    image: livekit/sip
    network_mode: host
    restart: unless-stopped
    environment:
      SIP_CONFIG_FILE: /etc/sip.yaml
    volumes:
      - ./sip.yaml:/etc/sip.yaml

volumes:
  redis_data:
  caddy_data:
Copy code
root@livekit:/opt/livekit# docker logs livekit-sip-1
open /sip/config.yaml: no such file or directory
t
Thanks — the restart loop error shows the container expects
/sip/config.yaml
. Update the sip service to mount the host file to that path and set the env var accordingly. Replace your current sip section with this:
Copy code
sip:
  image: livekit/sip
  network_mode: host
  restart: unless-stopped
  environment:
    - SIP_CONFIG_FILE=/sip/config.yaml
  volumes:
    - ./sip.yaml:/sip/config.yaml
Then ensure
./sip.yaml
exists next to your compose file and contains valid fields (example):
Copy code
api_key: 'key_goes_here'
api_secret: 'secret_goes_here'
ws_url: 'ws://127.0.0.1:7880'
redis:
  address: 'localhost:6379'
sip_port: 5060
rtp_port_range_start: 10000
rtp_port_range_end: 20000
local_ip: '::'
logging:
  level: debug
After applying the change: 1. Recreate containers: ◦ docker compose down ◦ docker compose up -d 1. Check logs: ◦ docker logs livekit-sip-1 If you still see an error, tell me the exact log output and confirm: •
ls -l ./sip.yaml
shows the file exists and is readable, •
docker compose ps
shows the sip container name (so I can reference correct logs). Sources: Self-hosted SIP server | LiveKit docs | SIP APIs | LiveKit docs | Self-hosting the Ingress Service | LiveKit docs