I am configuring a MongoDB replica set using YAML syntax. However, I'd like to use MONGODB_HOME environment variable to point to the database:
storage:
dbPath: "ENV['MONGODB_HOME']/data/db"
I've tried using %, $, etc, but without success. Is it possible to do so?
Just in case, I'm working under Windows 7 64 bit.
Best regards
The MongoDB config file (as at 3.0) only allows for static configuration values.
If you want to pass dynamic values you could invoke via the command line or a PowerShell script instead, eg:
mongod.exe --dbpath %HOME%\data\db
If you're planning on starting up multiple MongoDB server instances (for example, for different users) you'll also want to specify unique --port
numbers to listen to.
I have had some success setting a location with
volumes:
- mongo:/data/db
As part of a docker-compose.yml, which means I don't have to use the --dbpath CL switch.