Docker container delete all my dashboards

Hello,

I have a Grafana server configured in Docker this way:

  grafana:
    image: grafana/grafana
    container_name: grafana
    restart: always
    ports:
      - 3000:3000
    links:
      - influxdb

Every time I upgrade the image [docker-compose pull] y lost all my dashboards. My InfluxDB is in the DB, but I need to create the dashboards quieris again.

How could I keep my dashboard everytime I upgrade the container?

Thanks for your help.

Thanks!

I configured this way:

 grafana:
    image: grafana/grafana
    container_name: grafana
    restart: always
    volumes:
      - $PWD/docker_data/grafana/data:/var/lib/grafana
      - $PWD/docker_data/grafana/config:/etc/grafana
    ports:
      - 3000:3000
    links:
      - influxdb

The problem now is permisions, this is the grafana container log:

GF_PATHS_CONFIG='/etc/grafana/grafana.ini' is not readable.,
GF_PATHS_DATA='/var/lib/grafana' is not writable.,
You may have issues with file permissions, more information here: http://docs.grafana.org/installation/docker/#migration-from-a-previous-version-of-the-docker-container-to-5-1-or-later,
mkdir: can't create directory '/var/lib/grafana/plugins': Permission denied,

This is the user permissions on the host:

$ ls -lh docker_data/grafana/
total 8,0K
drwxr-xr-x 2 root root 4,0K feb 14 12:24 config
drwxr-xr-x 2 root root 4,0K feb 14 12:24 data

Anyone running persistant data in docker?

Thanks for your help.

Doc is your very good friend. You may save time if you read whole Grafana docker doc: https://grafana.com/docs/grafana/latest/installation/configure-docker/#run-grafana-container-using-bind-mounts

Thanks for the link.

I read all the page, but it doesn’t work.

I try:

  • Use -user xxxx (my user ID)
  • chown -R 104:104 directory
  • chown -R 472:472 directory

But nothing.

I will really appreciate your help.

Best regards.