One value, three ways to write it
A Basic Auth hash right in compose — every $ doubled:
- "traefik.http.middlewares.auth.basicauth.users=admin:$$apr1$$xyz$$…"
The same hash in .env — single $ and single quotes:
APP_AUTH='admin:$apr1$xyz$…'
Compose keeps a reference:
- "traefik.http.middlewares.auth.basicauth.users=${APP_AUTH}"
Without quotes in .env, compose takes $apr1 for a variable and substitutes nothing — the hash breaks without
a single error.
If it doesn’t work
Moved a Basic Auth hash into .env — the password stopped working
- Cause
- The value has no quotes: compose took
$apr1for a variable and substituted nothing. No error is raised. - Fix
- Wrap the value in single quotes:
APP_AUTH='admin:$apr1$xyz$…'.
How to check
The config hash before and after the move should match (The compose config hash):
docker compose config --hash '*'