Handle quotes in --env-file values consistently with Linux/WSL2 "source"ing #3630
Description
Hi there,
I use a .env
file to supply env vars for my application both when running locally and in a Docker container.
When running my application in Linux/WSL2 (Ubuntu), I source
the .env
file before running.
Example:
set -o allexport
source ./myVars.env
set +o allexport
And when running my application in Docker Desktop on Windows I use the --env-file option to specify the .env
file:
docker run --env-file .\myVars.env <etc>
Unfortunately, some of the env var values in the .env
file need to contain spaces. This means they must be double-quoted to work correctly when source
ing in Linux. However when quoted, the parsing in docker run
does not remove the quotes making the values invalid as they contain literal quote marks at beginning and end.
The consequence of this is I need to maintain a second (mostly duplicate) .env
file for Docker use.
I would much prefer if docker run
could parse .env
files in the same way as my Linux source
ing does and in line with the general shell concept that quotes are a guide to how a string should be interpreted - not part of the string itself.
From searching, it seems this has been fixed in docker compose
(docker/compose#8388). Please can you also fix it in docker run
?
Activity