Loys Caucheteux
Loys Caucheteux

Reputation: 349

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.

Upvotes: 8

Views: 22563

Answers (3)

Sumanta
Sumanta

Reputation: 47

You might have taken a basic understanding of this error. It happens mainly because of permission. To tackle this you can follow any one of the below steps: Anyone can work for you.

  1. You can run this cmd while running up docker-compose

    docker-compose up --force-recreate

  2. In your compose .yml file add the user as root like:

version: "3.8"
services:
  grafana:
      
    image: "grafana/grafana:8.2.6"
    command: bash -c "docker login -u user -p password && /run.sh"
    ports:
      - "192.168.1.31:5433:3000"
    volumes:
      - /home/grafana_hosting/app_data:/var/lib/grafana
    user: "root:root"

Upvotes: 4

Hannan
Hannan

Reputation: 125

Just replace your user's id that you will get on the following command:

$ id -u

Im running 'id -u' in my terminal and getting '1000'. SO, I replaced user: "xxxx" to user: "1000" in docker-compose.yml

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: "1000"

Upvotes: 1

Loys Caucheteux
Loys Caucheteux

Reputation: 349

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 !

Upvotes: 16

Related Questions