Option 1, docker volumes
With persistent storage you have a few different options. You can create a docker volume and in vanilla docker that will work with the file permissions for the Grafana docker container (id = 472, group = 472).
version: '3'
services:
grafana:
image: grafana/grafana:5.2.4
volumes:
- grafana-storage:/var/lib/grafana
ports:
- 3000:3000
volumes:
grafana-storage:
Option 2, using a folder on your local filesystem
When using a local folder you need to do a little bit of extra work to make it so that the docker container can read the contents of the folder as well as write to it. In the example below we will modify the user that Grafana runs as within the container so that it runs as the same user id as you do in your local file system, this will guarantee that it has access if you do.
-
mkdir gfdata
-
id -u
(this will give you your user id, which you will enter into the docker-compose file. In my case it is 1001, replace 1001 in the docker-compose file with your id) -
docker-compose.yml
version: '3'
services:
grafana:
image: grafana/grafana:5.2.4
user: "1001"
volumes:
- ./gfdata:/var/lib/grafana
ports:
- 3000:3000
I hope this helps clearing up some of the confusion.