Grafana docker /etc/grafana/grafana.ini is not readable

Viewed 2138

Context

I am trying to use grafana with docker and provide my dashboards automaticaly.

Everything works when i run it on my developpement computer (Windows), but when i try to deploy it on a linux server i have permissions error.

Files

Here is my Dockerfile inside my grafana folder

FROM grafana/grafana:8.2.1
ADD ./provisioning /etc/grafana/provisioning
ADD ./config.ini /etc/grafana/config.ini
ADD ./dashboards /app/grafana/dashboards

Here is my docker-compose.yml

version: '3.3'
services:
  grafana:
    build: './grafana'
    container_name: 'grafana'
    ports:
      - '127.0.0.1:3030:3000'
    volumes:
     - ./grafana/data:/var/lib/grafana
    user: '472'

What i did

First i cloned my repository from github. Then i ran docker-compose up and inside the logs i have some errors:

grafana         | GF_PATHS_CONFIG='/etc/grafana/grafana.ini' is not readable.
grafana         | GF_PATHS_DATA='/var/lib/grafana' is not writable.
grafana         | GF_PATHS_HOME='/usr/share/grafana' is not readable.
grafana         | You may have issues with file permissions, more information here: http://docs.grafana.org/installation/docker/#migrate-to-v51-or-later
grafana         | mkdir: can't create directory '/var/lib/grafana/plugins': Permission denied

I read the documentation on http://docs.grafana.org/installation/docker/#migrate-to-v51-or-later but i did not find any solution.

I tried to do theses steps with both my root user and my non root user but i have the same result.

Everything work fine on my windows computer but not on my linux, with exacly the same files.

1 Answers

You can try passing the config as environment variables in the docker-compose file

For example:

If you have this in your config.ini

[security]
admin_user = dummyuser
admin_password = dummypass1234

[auth.anonymous]
enabled=true

In your docker-compose file you would pass them as:

  grafana:
    image: grafana/grafana:latest
    ports:
      - '3000:3000'
    volumes:
      - ./grafana/data/:/var/lib/grafana
      - ./grafana/provisioning/:/etc/grafana/provisioning
    environment:
      - GF_SECURITY_ADMIN_USER=dummyuser
      - GF_SECURITY_ADMIN_PASSWORD=dummypass1234
      - GF_AUTH_ANONYMOUS_ENABLED=true
      # - GF_PATHS_CONFIG="./config.ini:/etc/grafana/config.ini"
Related