Grafana & Docker: several errors in permissions

Hi,
I’m trying to install grafana via docker container.
Unfortunately I got some error running the container related to permisions:

GF_PATHS_CONFIG='/etc/grafana/grafana.ini' is not readable.
GF_PATHS_DATA='/var/lib/grafana' is not writable.
GF_PATHS_HOME='/usr/share/grafana' is not readable.
You may have issues with file permissions, more information here: http://docs.grafana.org/installation/docker/#migrate-to-v51-or-later
✔ Downloaded and extracted grafana-clock-panel v2.1.3 zip successfully to /var/lib/grafana/plugins/grafana-clock-panel

Please restart Grafana after installing or removing plugins. Refer to Grafana documentation for instructions if necessary.

logger=settings t=2023-07-11T13:45:14.499113863Z level=info msg="Starting Grafana" version=10.0.2 commit=b2bbe10fbc branch=HEAD compiled=2023-06-30T08:34:22Z
logger=settings t=2023-07-11T13:45:14.499568733Z level=warn msg="\"sentry\" frontend logging provider is deprecated and will be removed in the next major version. Use \"grafana\" provider instead."
logger=settings t=2023-07-11T13:45:14.499599714Z level=info msg="Config loaded from" file=/usr/share/grafana/conf/defaults.ini
logger=settings t=2023-07-11T13:45:14.499610511Z level=info msg="Config loaded from" file=/etc/grafana/grafana.ini
logger=settings t=2023-07-11T13:45:14.499619805Z level=info msg="Config overridden from command line" arg="default.paths.data=/var/lib/grafana"
logger=settings t=2023-07-11T13:45:14.499628759Z level=info msg="Config overridden from command line" arg="default.paths.logs=/var/log/grafana"
logger=settings t=2023-07-11T13:45:14.499637518Z level=info msg="Config overridden from command line" arg="default.paths.plugins=/var/lib/grafana/plugins"
logger=settings t=2023-07-11T13:45:14.499645886Z level=info msg="Config overridden from command line" arg="default.paths.provisioning=/etc/grafana/provisioning"
logger=settings t=2023-07-11T13:45:14.499654699Z level=info msg="Config overridden from command line" arg="default.log.mode=console"
logger=settings t=2023-07-11T13:45:14.499664008Z level=info msg="Config overridden from Environment variable" var="GF_PATHS_DATA=/var/lib/grafana"
logger=settings t=2023-07-11T13:45:14.499672953Z level=info msg="Config overridden from Environment variable" var="GF_PATHS_LOGS=/var/log/grafana"
logger=settings t=2023-07-11T13:45:14.499681424Z level=info msg="Config overridden from Environment variable" var="GF_PATHS_PLUGINS=/var/lib/grafana/plugins"
logger=settings t=2023-07-11T13:45:14.499735822Z level=info msg="Config overridden from Environment variable" var="GF_PATHS_PROVISIONING=/etc/grafana/provisioning"
logger=settings t=2023-07-11T13:45:14.499748918Z level=info msg=Target target=[all]
logger=settings t=2023-07-11T13:45:14.499764876Z level=info msg="Path Home" path=/usr/share/grafana
logger=settings t=2023-07-11T13:45:14.49977367Z level=info msg="Path Data" path=/var/lib/grafana
logger=settings t=2023-07-11T13:45:14.499782333Z level=info msg="Path Logs" path=/var/log/grafana
logger=settings t=2023-07-11T13:45:14.499791581Z level=info msg="Path Plugins" path=/var/lib/grafana/plugins
logger=settings t=2023-07-11T13:45:14.499800484Z level=info msg="Path Provisioning" path=/etc/grafana/provisioning
logger=settings t=2023-07-11T13:45:14.499808857Z level=info msg="App mode production"
logger=sqlstore t=2023-07-11T13:45:14.500295067Z level=info msg="Connecting to DB" dbtype=sqlite3
logger=migrator t=2023-07-11T13:45:14.540456723Z level=info msg="Starting DB migrations"
logger=migrator t=2023-07-11T13:45:14.551076643Z level=info msg="migrations completed" performed=0 skipped=485 duration=1.094782ms
logger=secrets t=2023-07-11T13:45:14.55220525Z level=info msg="Envelope encryption state" enabled=true currentprovider=secretKey.v1
logger=local.finder t=2023-07-11T13:45:14.750050865Z level=warn msg="Skipping finding plugins as directory does not exist" path=/usr/share/grafana/plugins-bundled
logger=plugin.loader t=2023-07-11T13:45:14.80332523Z level=info msg="Plugin registered" pluginID=grafana-clock-panel
logger=query_data t=2023-07-11T13:45:14.809114826Z level=info msg="Query Service initialization"
logger=live.push_http t=2023-07-11T13:45:14.814890298Z level=info msg="Live Push Gateway initialization"
logger=infra.usagestats.collector t=2023-07-11T13:45:17.532240534Z level=info msg="registering usage stat providers" usageStatsProvidersLen=2
logger=provisioning.alerting t=2023-07-11T13:45:17.533046197Z level=info msg="starting to provision alerting"
logger=provisioning.alerting t=2023-07-11T13:45:17.533081906Z level=info msg="finished to provision alerting"
logger=modules t=2023-07-11T13:45:17.536087884Z level=warn msg="No modules registered..."
logger=http.server t=2023-07-11T13:45:17.542790547Z level=info msg="HTTP Server Listen" address=[::]:3000 protocol=http subUrl= socket=
logger=ngalert.state.manager t=2023-07-11T13:45:17.546494697Z level=info msg="Warming state cache for startup"
logger=ngalert.state.manager t=2023-07-11T13:45:17.546971211Z level=info msg="State cache has been initialized" states=0 duration=474.846µs
logger=ticker t=2023-07-11T13:45:17.547150192Z level=info msg=starting first_tick=2023-07-11T13:45:20Z
logger=grafanaStorageLogger t=2023-07-11T13:45:17.5564416Z level=info msg="storage starting"
logger=ngalert.multiorg.alertmanager t=2023-07-11T13:45:17.56838119Z level=info msg="starting MultiOrg Alertmanager"
logger=grafana.update.checker t=2023-07-11T13:45:17.613542356Z level=info msg="Update check succeeded" duration=64.90097ms
logger=plugins.update.checker t=2023-07-11T13:45:17.679368642Z level=info msg="Update check succeeded" duration=127.30366ms

I double checked permission but it looks all right.
This is docker-compose entry:

grafana:
    image: grafana/grafana-oss
    container_name: grafana
    restart: unless-stopped
    user: '472:0'
    environment:
     - GF_INSTALL_PLUGINS=grafana-clock-panel
    ports:
     - '3000:3000'
    volumes:
     - /opt/data/depot/docker/grafana:/var/lib/grafana
     - /opt/data/depot/docker/grafana/grafana.ini:/etc/grafana/grafana.ini
ls -la /opt/data/depot/docker/grafana/
total 968
drwx------.  8 grafana root    119 Jul 11 15:45 .
drwxr-xr-x. 12 root    root    172 Jul 11 14:34 ..
drwxr-x---.  3 grafana root     15 Jul 11 14:35 alerting
drwx------.  2 grafana root      6 Jul 11 14:35 csv
-rw-r-----.  1 grafana root 929792 Jul 11 15:45 grafana.db
-rwxr--r--.  1 grafana root  58845 Jul 11 14:27 grafana.ini
drwxr-xr-x.  2 grafana root      6 Jul 11 14:35 log
drwx------.  2 grafana root      6 Jul 11 14:34 logs
drwxr-xr-x.  3 grafana root     33 Jul 11 15:45 plugins
drwx------.  2 grafana root      6 Jul 11 14:35 png
 grep grafana /etc/passwd
grafana:x:472:0::/opt/data/depot/docker/grafana:/bin/false

I also tried to read grafana.ini from inisde the container and touchign a file:


docker exec -it grafana bash
e6fdf2862163:/usr/share/grafana$ head /etc/grafana/grafana.ini
##################### OK Grafana Configuration Example #####################
#
# Everything has defaults so you only need to uncomment things you want to
# change

# possible values : production, development
;app_mode = production

# instance name, defaults to HOSTNAME environment variable value or hostname if HOSTNAME var is empty
;instance_name = ${HOSTNAME}
e6fdf2862163:/usr/share/grafana$ touch /var/lib/grafana/from_inside_the_container
ls -la /opt/data/depot/docker/grafana/
total 968
drwx------.  8 grafana root    152 Jul 11 15:57 .
drwxr-xr-x. 12 root    root    172 Jul 11 14:34 ..
drwxr-x---.  3 grafana root     15 Jul 11 14:35 alerting
drwx------.  2 grafana root      6 Jul 11 14:35 csv
-rw-r--r--.  1 grafana root      0 Jul 11 15:57 from_inside_the_container
-rw-r-----.  1 grafana root 929792 Jul 11 15:55 grafana.db
-rwxr--r--.  1 grafana root  58845 Jul 11 14:27 grafana.ini
drwxr-xr-x.  2 grafana root      6 Jul 11 14:35 log
drwx------.  2 grafana root      6 Jul 11 14:34 logs
drwxr-xr-x.  3 grafana root     33 Jul 11 15:45 plugins
drwx------.  2 grafana root      6 Jul 11 14:35 png

So what is still wrong?

Thanks

Mmmmm the key in fact was the auxiliary “may”.
It mislead me thinkind there was somthing wrong.
Anyway I tested all again as suggested now it works fine despite the log message.

Thanks!

1 Like