I have an env variable value like this:
TEST_VAR=The value
Do anybody knowns whether this is legal? should I place "
around the value for this to be interpreted as needed in docker?
Thanks
EDIT: Quotation marks will not be a good solution as it is will be part of the val see reference here.
You can escape the space with a
\
:Edit: This is how I pass them when starting the container (i.e.
docker run -e TEST_VAR=The\ value hello-world
). If you're usingdocker-compose
or an env file, see the answer by @yamenk.In Dockerfile use doublequotes, do not use singlequotes because they do not expand variables inside, excerp from passing buildargs/envs to dockerfile and into a python script below:
Lets see the result running the following compose file:
env.conf:
docker-compose up
Result:Therefore, it is legal to have spaces in the env value.