beware if stops or remove grafana docker container (all the dashboards, users and configs will be deleted)
when start again the container, there are’nt data
This happens because, by default, Docker containers are ephemeral.
Everything you write inside them is saved in a temporary write layer that is destroyed when the container is deleted or recreated
if you want persist users, dashboards and config, add this to docker-compose.yml:
volumes:
- grafana-storage:/var/lib/grafana
It creates a volume called grafana-data. The first time it starts, Grafana fills that folder. When you stop or delete the container, the data remains “outside” on the volume. When you restart the container, Docker recognizes the volume and returns the data to it
If you prefer not to use Compose, you must add the -v flag when running the command
docker run -d \
-p 3000:3000 \
--name=grafana \
-v grafana-storage:/var/lib/grafana \
grafana/grafana-oss
example
services:
grafana:
image: grafana/grafana-oss:latest
container_name: grafana
ports:
- "3000:3000"
volumes:
- grafana-storage:/var/lib/grafana
volumes:
grafana-storage: