dockerdocker-composepermissionsgrafanauserid

Having permissions issues with Grafana 7.3.0 on Docker


I'm using docker-compose to create a Docker network of containers with InfluxDB, a python script and Grafana to harvest and visualize response codes, query times & other stats of different websites.

I am using Grafana image 7.3.0 with a volume, I have modified the paths environment variables so I'll have to use only one volume to save all the data.

When I start the Grafana container it logs:

GF_PATHS_CONFIG='/etc/grafana/grafana.ini' is not readable.
GF_PATHS_DATA='/etc/grafana/data' is not writable.
GF_PATHS_HOME='/etc/grafana/home' is not readable.

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 '/etc/grafana/plugins': Permission denied

But here is the thing, I'm not migrating from below 5.1 I'm not even migrating at all!

So I tried to follow their instruction to change permissions of files but it did not worked.

I tried to set the user id in the docker-compose but it did not help.

(as-said in the docs 472 == post 5.1, 104 == pre 5.1 but both did not worked)

I can't even change permissions manually (which is not a satisfying solution btw) because the container is crashing.

I normally don't ask questions because they already have answers but I've seen no one with this trouble using 7.3.0 so I guess it's my time to shine Haha.

Here is my docker-compose.yml (only the grafana part)

version: '3.3'

services:
  grafana:
    image: grafana/grafana:7.3.0
    ports:
      - '3000:3000'
    volumes:
      - './grafana:/etc/grafana'
    networks:
      - db-to-grafana
    depends_on:
      - db
      - influxdb_cli
    environment:
      - GF_PATHS_CONFIG=/etc/grafana/grafana.ini
      - GF_PATHS_DATA=/etc/grafana/data
      - GF_PATHS_HOME=/etc/grafana/home
      - GF_PATHS_LOGS=/etc/grafana/logs
      - GF_PATHS_PLUGINS=/etc/grafana/plugins
      - GF_PATHS_PROVISIONING=/etc/grafana/provisioning
   user: "472"

Thank you very much for your potential help!

Edit : I've been wondering if there is a grafana user in latest version (8.0), I think that build a home dir for grafana using a Dockerfile could be the solution I just need to find that user.


Solution

  • I'm here to close this subject.

    So this was kind of a noob mistake but I could not have known. The problem came from the fact that Grafana won't chown and chmod the volume folder. The error does not occures but it won't work because it does not save the data.

    The solution was to remove the env variables and changing permissions of the local './grafana' folder wich contained the volume.

    So I did

    chown -R <personal local user> /path/to/local/volume/folder && \
    chmod -R 777 /path/to/local/volume/folder
    

    And now it works normally Here is my new docker compose

       docker-compose.yml   
        grafana:
            image: grafana/grafana
            ports:
              - '3000:3000'
            volumes:
              - './grafana:/var/lib/grafana'
            networks:
              - db-to-grafana
            depends_on:
              - db
              - influxdb_cli
    

    Thanks everybody four your help !