How to use custom ini file for Grafana with Docker?

I have like this container in my docker-compose file:

grafana:
  image: grafana/grafana
  ports:
    - '3000:3000'
  environment:
    - GF_PATHS_CONFIG="./grafana/etc/grafana.ini"
    - GF_INSTALL_PLUGINS=grafana-piechart-panel,grafana-worldmap-panel,vertamedia-clickhouse-datasource,vertamedia-chtable

Inside grafana.ini I tried change default admin login and password like this:

[security]

admin_user = user
admin_password = 1234

But it is doesn’t work for me. How I can use my custom .ini file with Grafana in Docker correctly?

Hello!

You should mount your config file into the docker container by using volumes like this:

  grafana:
    image: grafana/grafana
    ports:
      - "3000:3000"
    volumes:
      - ./custom.ini:/etc/grafana/grafana.ini

If you have very few configuration updates to do, you can also add them as env variables, like this:

  grafana:
    image: grafana/grafana
    ports:
      - "3000:3000"
    environment:
      GF_SECURITY_ADMIN_USER: user
      GF_SECURITY_ADMIN_PASSWORD: 1234
2 Likes