Docker Compose env_file silently escapes $$ to $ in values — SMTP/DB/API auth fails even though the password string is correct in .env
Diagnosis
Docker Compose applies its $$ → $ literal-escape sequence to env_file values, not just to YAML environment: blocks. Docs claim no substitution on env_file — but the escape IS applied. A password of ARJSARa99$$ in .env arrives at the container as ARJSARa99$. Generic auth failure masks the real cause. Shell-level docker exec sh -c 'echo $VAR' can hide it — the shell re-escapes on print.
Fix
Double every literal in env_file values. For password ARJSARa99$$, write SMTP_PASS=ARJSARa99$$$$ in .env. Verify with `docker exec CONTAINER printenv VAR | od -c` — only view showing exact bytes without shell re-escaping. Verified Docker Compose v5.0.2 on Ubuntu 24.04 (2026-04-18). Prevention: `od -c` the container env immediately after `up -d` when any secret contains, backtick, backslash, or !.