Changing grafana password in docker environment

Hi, I’m trying to change the default password from a docker stack containing amongst others, grafana. I’m using Balena to deploy the image. My end goal would be to use a service variable in balena. tied to the password for Grafana, the first step would be to change it not using variables, instead feeding the user and password straight.

As a default, the login is admin/admin. I can create a new account, or update the password in the interface, but once the container restart the changes are reverted back to default.

The two options I’ve explored is;

  • Editing the config.ini that shares a folder with the Dockerfile.
    adding;

[security]
admin_user = newuser
admin_password = newpassword

  • Editing the Docker Compose, adding;

environment:

  • GF_SECURITY_ADMIN_PASSWORD=“newpassword”
  • GF_SECURITY_ADMIN_USER=“newuser”

However, both these approaches lead to admin/admin not working, and newuser/newpassword not working when rebuilding the container.

The only way I can get access is not setting any of these variables, instead using the default admin/admin login.

Hi!

We had the same issue and solved it the following way:

Just like you, we used a custom.ini file for configuration and changed the values like so:

[security]

admin_user = newuser
admin_password = newpassword

To get Grafana to recognize that we are using a custom.ini file, we set the following environment variable:

"GF_PATHS_CONFIG=<path/to/your>/custom.ini"

Hope it helps!

1 Like

thanks it solves my problem after getting confused. :star_struck: