-
Notifications
You must be signed in to change notification settings - Fork 435
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
Option for Docker compatibility #92
Comments
Can you provide some examples? |
I looked for the example that spurred this request, but I'm not finding any .env values that have a quote at the beginning or end. I thought the example I encountered had a quote only at the beginning or end, but I don't see how that would have been an issue. Probably I re-generated a password to be compatible with both forms. More importantly, looking at the code, I don't see how that if statement ever evaluates to True. The Perhaps I encountered this issue by reading the README, which doesn't provide a detailed spec, but only examples that seem to contradict the Docker spec. Looking into it, the intended behavior may be the same except when matching quotes are included, such as
Which will produce But again, I don't have an active use-case. What I'd like to see is a declaration in the README that says that dotenv supports docker .env files (full stop). |
With the latest dotenv, your example yields My understanding is that python-dotenv attempts to mimic Bash, albeit incompletely. That's probably were those quoting rules come from, and why it differs from the format understood by docker-compose. There's even more to dotenv, like string interpolation (e.g. I'm afraid it would be impossible to support docker-compose environment files without adding an option to the dotenv API. I wonder if it would be worth it.
Surprisingly, this would actually work. For instance: >>> 0 == 0 in [1]
False
>>> 0 == 1 in [1]
False
>>> 1 == 1 in [1]
True
>>> 2 == 2 in [1]
False However, this code was indeed very hard to understand and would fail on strings of one character (e.g. |
Wow. Okay, I've been doing Python for over 20 years and I learned something new today. I was still thinking like a C programmer, and I'd not realized that certain operations are chained left-to-right, as explained here. I knew that was true for
It would be immensely useful in my use-case, where in development I need to switch between running natively and running the same process under docker compose. Right now, I can't do that without:
Honestly, I'd prefer that bash and docker-compose and dotenv could all agree on a format so that one didn't have to maintain separate env files for each platform. Annoyingly, it seems docker compose is happy with their non-standard syntax. I do agree that docker-compose seems to be the odd-player out here. |
I was hoping to use python-dotenv to re-use the env file created for Docker. The Docker syntax, however, conflicts with the python-dotenv syntax (in how it interprets quotes).
Should python-dotenv provide a mode that's compatible with Docker's syntax?
The text was updated successfully, but these errors were encountered: