Open guzman-raphael opened 2 months ago
This looks similar to / related to https://github.com/docker/cli/issues/4665#issuecomment-1821862464
The format used for files specified by --env-file
are expected to be line-delimited (name[=<value>]
) and doesn't support multi-line values or quoting. Note that the --env-file
option on docker run
/ docker create
is not the equivalent of .env
files (as used by compose).
It appears compose uses WithEnv(env ...string)
while the cli uses parseKeyValueFile(filename string, emptyFn func(string)
for parsing environment variables.
I'm a new contributor, but if you want I can push a pr for a test case of using a bad header with a space such as [config 1]
in order to document this is expected behavior. If in the future it is decided to allow environment headers with spaces the test case can be updated.
Description
Encountered an inconsistency in one of my projects. Perhaps it could be user error or a misunderstanding but it is related to how
docker run
behaves compared todocker compose run
.Left a minimal example below but happy to provide more info if it is not clear enough.
Please let me know if this is the appropriate tracker to file this under.
Reproduce
test.env
using a multiline variable like so:docker run
:However, the following works as expected using the same
test.env
from above.docker-compose.yaml
file like so:docker compose run
:Returns with:
Expected behavior
Expected
docker run
anddocker compose run
to behave similarly in these cases.docker version
docker info
Additional Info
This is a simplified example of a larger use case where I am setting some sensitive settings in GitHub Secrets and was trying to avoid an extra step of base64 encoding since it makes it less readable. A space is required in the spec for the setting.
Normally, I'd proceed with
docker compose run
version, however, I am not calling it directly. VSCode+DevContainer is callingdocker run
during the creation of the environment.Alternative suggestions welcome.
Related to docker/compose#6951 though using
docker compose
worked fine for me.