First of all, the documentation I’m reading for Docker setup is really really bad:
Basically there’s VERY little mention of how to set up the bind mounts / volume mounts for data persistence here. I’m simply using Docker Compose to host Promtail + Loki + Grafana in my home lab setup. I just wanted something simple, not an enterprise or complex setup. Each time I bring down my containers and start them up again, the data inside that container is wiped out and I lose all my settings. Of course, because there’s no volumes or directories mounted.
A few things I tried:
- In Grafana, mount
/var/lib/grafanato persist changes made in the web UI
- In Grafana and other apps, try mounting
/etc/grafana(similar paths for loki and promtail) to get the INI/YAML files for configuration, but these files are NOT created if these directories are mounted. I get permissions errors in Grafana’s case.
I think the above last point is more important in the Promtail/Loki case since they require the YAML configuration files to even start, but it’s unclear from the documentation if I should be mounting
/etc/promtail or use
/mnt/config as they do in the documentation.
I’ll provide my final YAML below, can anyone help me understand if I am setting this up properly? The mounts I got by trial and error mostly.
version: "3" networks: loki: services: loki: image: grafana/loki # restart: unless-stopped user: $DOCKER_UID:$DOCKER_GID command: -config.file=/mnt/config/config.yml networks: loki: ports: - 3100:3100 volumes: - ./loki:/mnt/config - /etc/timezone:/etc/timezone:ro environment: - TZ=America/Chicago promtail: image: grafana/promtail # restart: unless-stopped # user: $DOCKER_UID:$DOCKER_GID command: -config.file=/mnt/config/config.yml networks: loki: ports: - 9080:9080 volumes: - ./promtail:/mnt/config - /var/log:/var/log:ro - /etc/timezone:/etc/timezone:ro environment: - TZ=America/Chicago grafana: image: grafana/grafana user: $DOCKER_UID:$DOCKER_GID networks: loki: ports: - 3000:3000 volumes: - ./grafana/data:/var/lib/grafana - /etc/timezone:/etc/timezone:ro environment: - TZ=America/Chicago
Eventually, I’m going to want Promtail to monitor other log files mounted from other containers, as well as container logs themselves, and I’m not sure if I need to do all of this in a single Promtail container (I’d end up adding a bunch more bind mounts) or if you create 1 Promtail container for each app.
Thanks in advance for helping me get started.