-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
support newlines in env files #3527
Comments
Why is this closed? |
@sandrodz shin- just closed duplicate issue of this. This issue is still open. I also think it's convenient if env_file supports newline. |
+1 |
This feature will be really useful in cases when env variables may be quite long. E.g. in an email forwarder. I was trying different variations of the following in my
|
EDIT: This works with normal environment variables, so it's weird that it doesn't work with Example: export TEST="This is line 1
This is line 2
This is line 3" Compose file version: '2'
services:
test:
image: debian:jessie
command: echo "$TEST"
environment:
- TEST=${TEST}
|
Yaeh... If you are wrapping compose to do this, you could also just generate the yaml with another tool. |
Would love to see multi-line .env file support! |
We can only support multi-line values in env files if they're also supported in Engine (i.e. Currently, newlines don't seem to be supported in Engine. The latest discussion I can find seems to be here: moby/moby#12997 |
It should be possible to hack around it, right? |
The hack for those who are lazy: moby/moby#12997 (comment) |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically closed because it had not recent activity during the stale period. |
In a large config base, this is a real pain point. Does someone have a (almost) 2020 workaround for this? (Also, there is this proposal for a fix.) |
I, too, would love to see this resolved. |
Invidious gained support to read its configuration from an env var instead of config file in e3c10d7. Unfortunately, Docker doesn't allow newline characters in env var values (see [0]) which means we can only provide a proper YAML config by using the inlined configuration in docker-compose.yml which, unfortunately, is tracked by Git. Once support for multiline env var values has been added to Docker, we should migrate and read the config from a .env file instead (which is not tracked by Git). [0]: docker/compose#3527
Invidious gained support to read its configuration from an env var instead of config file in e3c10d7. Unfortunately, Docker doesn't allow newline characters in env var values (see [0]) which means we can only provide a proper YAML config by using the inlined configuration in docker-compose.yml which, unfortunately, is tracked by Git. Once support for multiline env var values has been added to Docker, we should migrate and read the config from a .env file instead (which is not tracked by Git). [0]: docker/compose#3527
Small workaround, if
Then just source the
If you want to be able to overwrite the envs via
|
Please reopen and fix... |
According to dotenv's documentation (link), which is used to parse the envfiles within Docker Compose, one should use double quotations with new-lines ( Example:
|
When i try this, i get a double backslash -----BEGIN PRIVATE KEY-----\nMIGHAgEAMBMGByqGSM49AgEGCCqGSU72AwEHBG0wawIBAQQgf+zcD+dC95xJH2YIGtZxg6cBEtZYzeMHZIdAtGarkfahRANCAAReRj+7DNK3rfudJGSo2k9mUBhmz2zqE3d4sfpkIGUizc1s8UXYmnhgezq6fceV9o6HG1I6BdVWi5cfbwTB17Qf\n-----END PRIVATE KEY----- |
@wichopy we use it like this:
|
Environment variable values can have new lines in them and docker-compose.yml already supports that because yml does:
However, the env file syntax doesn't support this. It looks like it doesn't do anything more than split on newlines and the first
=
sign.compose/compose/config/environment.py
Line 16 in 86b5ed1
One way would be to allow quoted strings in the env file. This is not backwards compatible because anyone who already has a quoted string in their env file would see unexpected behaviour. Hopefully someone else has a better idea?
The text was updated successfully, but these errors were encountered: