With docker-compose
v2 environment variables can be set by simply:
enviroment:
- MONGO_PATH=mongodb://db-mongo:27017
The ful
Environment variables (including their name), have to be fully wrapped inside single or double quotes: ""
or ''
environment:
- 'NODE_CONFIG={"database": {"data": {"host": "mongo"}, "session": {"host": "redis" }}}'
And using double quotes:
environment:
- 'PORT=3000'
- "NODE_CONFIG={\"database\": {\"data\": {\"host\": \"mongo\"}, \"session\": {\"host\": \"redis\" }}}"
It is remarkable to note that using double quotes ""
, like bash, will allow placing variables inside the environment variable.
"MY_HOME_ENV_VARIABLE=${HOME}"