Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to have root permission in the Grafana Docker container?

I have a Grafana Docker container, when I make an interactive shell on this, this user is not a superuser, so I can't do something that needs the sudo permission:

docker exec -it grafana_service bash

In this container:

$ su
password:

I haven't any password!

Or I can't use from chmod 777 to make full permission on a filesystem and etc.


This is my docker-compose:

version: '3'

services:
  grafana_sevice:
      image: grafana/grafana:5.1.3
      container_name: grafana_service
      restart: unless-stopped
      ports:
        - "3010:3000"
      links:
        - another_service
like image 939
Benyamin Jafari Avatar asked Dec 14 '22 15:12

Benyamin Jafari


2 Answers

I found the solution:

$ docker exec -it -u 0 grafana_service bash
# chmod 777 /var/lib/grafana/grafana.db

(Thanks to @c4f4t0r)

like image 100
Benyamin Jafari Avatar answered Feb 23 '23 22:02

Benyamin Jafari


By default the Grafana container will run with uid/gid 472, so you can chown -R 472:472 /your/grafana/dir on the host, then the container will be able to write to it.

like image 44
AussieDan Avatar answered Feb 23 '23 21:02

AussieDan