[SOLVED] Grafana permission denied with docker on CentOS7

I’m trying to setup prometheus and grafana using docker on Cent OS 7.

I never really used docker nor grafana.

This is my command:

sudo docker run -d -p 3000:3000 --user grafana --name grafana -e "GF_SECURITY_ADMIN_PASSWORD=changeme" -v ~/grafana_db:/var/lib/grafana grafana/grafana

Checking the logs sudo docker logs <containerid>

GF_PATHS_DATA='/var/lib/grafana' is not writable.
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: cannot create directory '/var/lib/grafana/plugins': Permission denied

The permissions for that folder are:drwxr-xr-x 3 grafana grafana 4096 Dec 18 21:33 grafana

This tells me the folder belong to the user grafana, and have read/write permissions.

From that point, I’m stuck.

I want to run the container as grafana user and use a host folder for my storage and configuration. Unless I missed it, checking the installation instruction on the website didn’t help very much.

What’s the problem?

Thanks!

I realised that my permissions needed to be for user/group 472, not grafana, on the host.
It’s fixed.

So the directory that is mapped into the grafana should have the 472 uid on it ?

like

sudo chown -R 472:472 /mnt/data/grafana/

3 Likes

In side container I am also having same issue:
bash-5.1$ chown -R 472:472 /etc/grafana/
chown: /etc/grafana/ldap.toml: Operation not permitted
chown: /etc/grafana/provisioning/plugins: Operation not permitted
chown: /etc/grafana/provisioning/plugins: Operation not permitted
chown: /etc/grafana/provisioning/notifiers: Operation not permitted
chown: /etc/grafana/provisioning/notifiers: Operation not permitted
chown: /etc/grafana/provisioning/dashboards: Operation not permitted
chown: /etc/grafana/provisioning/dashboards: Operation not permitted
chown: /etc/grafana/provisioning/datasources: Operation not permitted
chown: /etc/grafana/provisioning/datasources: Operation not permitted
chown: /etc/grafana/provisioning/access-control: Operation not permitted
chown: /etc/grafana/provisioning/access-control: Operation not permitted
chown: /etc/grafana/provisioning: Operation not permitted
chown: /etc/grafana/provisioning: Operation not permitted
chown: /etc/grafana/grafana.ini: Operation not permitted
chown: /etc/grafana/: Operation not permitted
chown: /etc/grafana/: Operation not permitted
bash-5.1$ sudo chown -R 472:472 /etc/grafana/
bash: sudo: command not found