michaelmiklis / docker-rpi-monitor

RPI Monitor from RPi-Experiences implemented in a Docker Container
Apache License 2.0
67 stars 34 forks source link

Storing data on host #1

Open neutralvibes opened 6 years ago

neutralvibes commented 6 years ago

First of all. This is great work.

As rpimonitor stores its rrd data in /var/lib/rpimonitor/stat/. If you like your containers to be able to be recreated without losing data, as I do, a suggestion would be to add a volume mapping to a localhost folder.

--volume=/your-local-path:/var/lib/rpimonitor/stat/ The rrd files will be stored locally and the container can be removed and recreated at will.

A systemd file could then be used which removed the container when stopped and recreates it started.

[Unit]
Description=rpi-monitor
Requires=docker.service
After=docker.service

[Service]
Restart=always
RestartSec=10s

ExecStart=/usr/bin/docker run --name=%n \
-p=8888:8888 \
--device=/dev/vchiq \
--restart=always \
--device=/dev/vcsm \
--volume=/opt/vc:/opt/vc \
--volume=/boot:/boot \
--volume=/sys:/dockerhost/sys:ro \
--volume=/etc:/dockerhost/etc:ro \
--volume=/proc:/dockerhost/proc:ro \
--volume=/usr/lib:/dockerhost/usr/lib:ro \
--volume=/var/lib/rpimonitor/stat/:/var/lib/rpimonitor/stat/ \
michaelmiklis/rpi-monitor:latest

ExecStop=/usr/bin/docker stop -t 2 %n ; /usr/bin/docker rm -f %n

[Install]
WantedBy=multi-user.target
lloydjatkinson commented 6 years ago

Having a volume for persistence should be in the Quick Start snippet, because otherwise it's pretty pointless.