custom.ini ignored with Grafana docker image

Viewed 3298

I have a strange issue with the grafana docker image: it totally ignores my custom.ini file.

The goal is to set the app_mode to development with no environment variables (otherwise it could be possible using GF_DEFAULT_APP_MODE: development in docker-compose).

Here is the interesting part of my docker-compose:

  grafana:
image: grafana/grafana:6.2.2
ports:
  - "3000:3000"
user: ${ID}
volumes:
  - "$PWD/data:/var/lib/grafana"
  - "$PWD/custom.ini:/etc/grafana/custom.ini"
  - "$PWD/custom.ini:/usr/share/grafana/conf/custom.ini"
  - "$PWD/custom.ini:/usr/share/grafana/conf/sample.ini"

As you can see, I tried a lot of locations (just in case).

I deploy the stack using the command: ID=$(id -u) docker-compose up -d

Except the config problem, Grafana works great. I can see my mounts correctly in the container, and the custom.ini file is well formatted (and I did not forget to remove the comment sign ;)

Here are the logs (we can see no mentions about a custom.ini or sample.ini):

Attaching to dev_grafana_1
grafana_1          | t=2019-06-11T14:20:44+0000 lvl=info msg="Starting Grafana" logger=server version=6.2.2 commit=07540df branch=HEAD compiled=2019-06-05T13:04:21+0000
grafana_1          | t=2019-06-11T14:20:44+0000 lvl=info msg="Config loaded from" logger=settings file=/usr/share/grafana/conf/defaults.ini
grafana_1          | t=2019-06-11T14:20:44+0000 lvl=info msg="Config loaded from" logger=settings file=/etc/grafana/grafana.ini
grafana_1          | t=2019-06-11T14:20:44+0000 lvl=info msg="Config overridden from command line" logger=settings arg="default.paths.data=/var/lib/grafana"
grafana_1          | t=2019-06-11T14:20:44+0000 lvl=info msg="Config overridden from command line" logger=settings arg="default.paths.logs=/var/log/grafana"
grafana_1          | t=2019-06-11T14:20:44+0000 lvl=info msg="Config overridden from command line" logger=settings arg="default.paths.plugins=/var/lib/grafana/plugins"
grafana_1          | t=2019-06-11T14:20:44+0000 lvl=info msg="Config overridden from command line" logger=settings arg="default.paths.provisioning=/etc/grafana/provisioning"
grafana_1          | t=2019-06-11T14:20:44+0000 lvl=info msg="Config overridden from command line" logger=settings arg="default.log.mode=console"
grafana_1          | t=2019-06-11T14:20:44+0000 lvl=info msg="Config overridden from Environment variable" logger=settings var="GF_PATHS_DATA=/var/lib/grafana"
grafana_1          | t=2019-06-11T14:20:44+0000 lvl=info msg="Config overridden from Environment variable" logger=settings var="GF_PATHS_LOGS=/var/log/grafana"
grafana_1          | t=2019-06-11T14:20:44+0000 lvl=info msg="Config overridden from Environment variable" logger=settings var="GF_PATHS_PLUGINS=/var/lib/grafana/plugins"
grafana_1          | t=2019-06-11T14:20:44+0000 lvl=info msg="Config overridden from Environment variable" logger=settings var="GF_PATHS_PROVISIONING=/etc/grafana/provisioning"
grafana_1          | t=2019-06-11T14:20:44+0000 lvl=info msg="Path Home" logger=settings path=/usr/share/grafana
grafana_1          | t=2019-06-11T14:20:44+0000 lvl=info msg="Path Data" logger=settings path=/var/lib/grafana
grafana_1          | t=2019-06-11T14:20:44+0000 lvl=info msg="Path Logs" logger=settings path=/var/log/grafana
grafana_1          | t=2019-06-11T14:20:44+0000 lvl=info msg="Path Plugins" logger=settings path=/var/lib/grafana/plugins
grafana_1          | t=2019-06-11T14:20:44+0000 lvl=info msg="Path Provisioning" logger=settings path=/etc/grafana/provisioning
grafana_1          | t=2019-06-11T14:20:44+0000 lvl=info msg="App mode production" logger=settings

I use the image grafana/grafana:6.2.2

Thanks for your help !

Note: I also tried a bunch of time to restart and even recreate my containers.

2 Answers

I just fixed this on my Grafana container, so perhaps this helps you. All I was trying to set was the SMTP config. I'm running Docker on Windows, so you will need to change the script for your needs of course. I am redirecting the data outside the container as well, so that config is included.

docker run -d -p 3000:3000 --name=grafana `
-v C:/DockerData/Grafana:/var/lib/grafana `
-v C:/DockerData/Grafana/custom.ini:/etc/grafana/grafana.ini `
grafana/grafana

I launch from powershell, so that is why ` is used for continue next line. Additionally, it did not like the local file being also called grafana.ini. It just would not start with that. So, hense you see the local file is custom.ini, yet I override the grafana.ini file. I hope this helps.

Ran into this issue as well. Apparently /etc/grafana/grafana.ini is the custom file on deb or rpm packages.

Note. If you have installed Grafana using the deb or rpm packages, then your configuration file is located at /etc/grafana/grafana.ini. This path is specified in the Grafana init.d script using --config file parameter.

So in your volumes section, update it to and it should pick up your custom settings:

volumes:
  - "$PWD/data:/var/lib/grafana"
  - "$PWD/grafana.ini:/etc/grafana/grafana.ini"
Related