Cannot Override default Admin user and passord

Hi all,

I tried, with Docker compose, to override the standard username and password using envirovment variables but the standards value are not overriden.

this is the code in my docker-compose.yaml

grafana:
image: grafana/grafana
depends_on:
- influxdb
restart: “no”
networks:
- iot
volumes:
- /var/lib/grafana:/var/lib/grafana
ports:
- “80:3000”
environment:
GF_SECURITY_ADMIN_USER: xxx
GF_SECURITY_ADMIN_PASSWORD: xxx2

I also tried:

environment:
  - "GF_SECURITY_ADMIN_USER=xxx"
  - "GF_SECURITY_ADMIN_PASSWORD=xxx2"

but doesn’t work.

What I’am doing wrong?

Thanks for helping

GF_SECURITY_ADMIN_PASSWORD only works the very first time you start Grafana - just in case that is your problem. Just did a quick test with docker run:

docker run -p 3003:3000 -e GF_SECURITY_ADMIN_USER=xxx -e GF_SECURITY_ADMIN_PASSWORD=test grafana/grafana:latest

On startup, I can see in the logs that the values got set:

t=2018-04-11T07:46:11+0000 lvl=info msg="Starting Grafana" logger=server version=5.0.0 commit=af6e283 compiled=2018-02-28T17:42:58+0000
t=2018-04-11T07:46:11+0000 lvl=info msg="Config loaded from" logger=settings file=/usr/share/grafana/conf/defaults.ini
t=2018-04-11T07:46:11+0000 lvl=info msg="Config loaded from" logger=settings file=/etc/grafana/grafana.ini
t=2018-04-11T07:46:11+0000 lvl=info msg="Config overridden from command line" logger=settings arg="default.paths.data=/var/lib/grafana"
t=2018-04-11T07:46:11+0000 lvl=info msg="Config overridden from command line" logger=settings arg="default.paths.logs=/var/log/grafana"
t=2018-04-11T07:46:11+0000 lvl=info msg="Config overridden from command line" logger=settings arg="default.paths.plugins=/var/lib/grafana/plugins"
t=2018-04-11T07:46:11+0000 lvl=info msg="Config overridden from command line" logger=settings arg="default.paths.provisioning=/etc/grafana/provisioning"
t=2018-04-11T07:46:11+0000 lvl=info msg="Config overridden from command line" logger=settings arg="default.log.mode=console"
t=2018-04-11T07:46:11+0000 lvl=info msg="Config overridden from Environment variable" logger=settings var="GF_SECURITY_ADMIN_USER=xxx"
t=2018-04-11T07:46:11+0000 lvl=info msg="Config overridden from Environment variable" logger=settings var="GF_SECURITY_ADMIN_PASSWORD=*********"

What do your logs look like? Do you have something similar to the the last two lines above.

2 Likes

Delete persistent Grafana storage with steps;

  1. Find all volumes

docker volume ls

  1. See where volumes with Grafana config and remove it

docker volume rm {grafana_config_volume}

  1. Rebuild everything from scratch.

By the way, notation with the equality sign works for me:
environment:

  • “GF_SECURITY_ADMIN_USER=xxx”
  • “GF_SECURITY_ADMIN_PASSWORD=xxx2”