Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$ in generated PASSWORD_SECRET can cause issues when parsed by Docker #634

Open
paulrobertlloyd opened this issue Jul 17, 2023 · 4 comments
Labels
documentation Good documentation benefits everyone

Comments

@paulrobertlloyd
Copy link
Collaborator

paulrobertlloyd commented Jul 17, 2023

Is your feature request related to a problem?

When setting up a Dockerfile, providing a generate PASSWORD_SECRET that contains a $ symbol, it gets parsed a separate variable. So, if for example the generated secret is:

$1a$10$ABC123

Docker compose would provide the following warning:

WARN[0000] The "ABC123" variable is not set. Defaulting to a blank string.

Describe the solution you’d like

When providing a value for PASSWORD_SECRET, escape the $ symbol.

So instead of providing:

$1a$10$ABC123

instead provide the following:

\$1a\$10\$ABC123

@paulrobertlloyd paulrobertlloyd added the enhancement New feature or request label Jul 17, 2023
@paulrobertlloyd
Copy link
Collaborator Author

Actually, using an escaped $ will mean an environment variable will not be parsed correctly in other environments. The above is purely a symptom of docker compose (see Variable substitution.

Rather that the suggestion above, instead mention needing to escape the dollar symbol in any documentation about saving the PASSWORD_SECRET variable when using Docker compose. Note also that the $ symbol can be escaped either as \$ or $$.

@paulrobertlloyd paulrobertlloyd added documentation Good documentation benefits everyone and removed enhancement New feature or request labels Jul 25, 2023
@jackdbd
Copy link
Contributor

jackdbd commented Feb 19, 2024

Same thing for .envrc files. Each $ in PASSWORD_SECRET (or any other environment variable) must be escaped.

@paulrobertlloyd
Copy link
Collaborator Author

Good to know. Is .envrc the same as .env?

@jackdbd
Copy link
Contributor

jackdbd commented Mar 4, 2024

Hey sorry, I missed the notification.

.envrc files are used by direnv.

direnv automatically loads the environment variables defined in an .envrc file when you enter a directory containing that file. And automatically unloads them when you exit that directory.

So basically .env and .envrc have the same purpose, but only with the combination of .envrc + direnv you gain this "automatic switching" of environments, which is super convenient when you are working on different projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Good documentation benefits everyone
Projects
None yet
Development

No branches or pull requests

2 participants