Docker swarm secret file not working

  • What Grafana version and what operating system are you using?
    Docker Version → 24.0.2
    Docker-compose → 1.29.2
    Ubuntu 22.04

  • What are you trying to achieve?
    I’m trying to use docker swarm secrets to securely configure credentials for my grafana using this variable - GF_SECURITY_ADMIN_PASSWORD_FILE=/run/secrets/password.pwd
    To achieve this I’m following this guide
    Docker Secrets in Grafana | DIT

  • How are you trying to achieve it?

  1. I setup a docker swarm
  2. I created a secret using this command echo “mypassword” | docker secret create password.pwd -
  3. I configured my docker-compose.yml to use the secret created in step 2
  4. I deploy my stack using: docker stack deploy -c docker-compose.yml stack_name
  • What happened?
  1. The stack start but it not take the password define in the secret (it still use the default “admin” password
  2. If I connect to my docker using docker exec -it xxxxxxxxx bash I can see the expected password with cat /run/secrets/password.pwd
  • What did you expect to happen?
  1. I expected that the grafana take the enviroment - GF_SECURITY_ADMIN_PASSWORD_FILE=/run/secrets/password.pwd
    (If I use - GF_SECURITY_ADMIN_PASSWORD=mypassword it works)
  • Can you copy/paste the configuration(s) that you are having problems with?

version: “3.9”

networks:
grafana_net:
name: grafana_net
external: true
internal_net:
name: internal_test

services:
grafana:
image: grafana/grafana:latest
volumes:
- grafanadata:/var/lib/grafana
- ./grafana.ini:/etc/grafana/grafana.ini
environment:
- GF_SECURITY_ADMIN_PASSWORD_FILE=/run/secrets/password.pwd
networks:
- grafana_net
- internal_net
secrets:
-
source: password.pwd
target: /run/secrets/password.pwd
mode: 0444

secrets:
password.pwd:
external: true

volumes:
grafanadata: {}

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    N/A

  • Did you follow any online instructions? If so, what is the URL?
    Docker Secrets in Grafana | DIT

Hi @epedersen

Try it seems that you are missing one additional underscore “_” as it requires 2 underscore between PASSWORD and FILE i.e.

GF_SECURITY_ADMIN_PASSWORD__FILE

Try this out and it should work

Thanks my friend, I cannot believe that I was fighting with this all weekend :smiley: