I've try to get env variables via mongo-initi.js and mongo docker-compose.yml , If it is possible to get mongodb docker containers env variable via mongo shell?
Asked
Active
Viewed 582 times
1 Answers
2
Which shell do you use? The legacy mongo shell (I prefer term "classic shell") or the new mongosh?
In the new mongosh, it is easy. The mongosh is a Node.js shell, simply use process.env
In legacy shell mongo you can use undocumented function _getEnv() or you pass environment variable in --eval, for example
mongo --eval "var my_var = '$MY_VAR';" ...
Wernfried Domscheit
- 54,457
- 9
- 76
- 110