How to use an environment variable for the basicauth.users label in the docker compose file?

Hi,

Instead of following line in my docker compose:

      - "traefik.http.middlewares.traefik_auth.basicauth.users=jan:$$apr1$$wg3z7sQp$$BXXXXXXXXXXXXXX7up/"

I tried to specify it using an environment variable as follows:

1/ in my .env I have specified the following:

BASIC_AUTH_USER_PASSWORD=jan:$$apr1$$wg3z7sQp$$BXXXXXXXXXXXXXX7up/

2/ and the above line in my docker compose file have been changed into:

- "traefik.http.middlewares.whoami_auth.basicauth.users=${BASIC_AUTH_USER_PASSWORD}"

... but this is not working.

How can I fix this ? Sharing a working example would help also.

Note that I am sure that my .env is properly processed when uploading the docker compose as it contains an environment variable that is properly used by my node-red docker container.

I got it fixed.

The problem is that in the .env file you don't need to double the $ in the hashed password as is needed when directly putting the hashed password in the docker compose file.

So updating the .env as follows fixed it:

BASIC_AUTH_USER_PASSWORD=jan:$apr1$wg3z7sQp$BXXXXXXXXXXXXXX7up/

TIP: you can also validate the actual hashed password used by traefik in your traefik dashboard (assuming you have enabled the dashboard).

wow thank you!!! I've been bashing my head against this for a bit... just removed the $$ and it works..