Hey all,
I have a docker-compose.yml that is committed in to a git version control.
It has an nfs volume set in it, and it looks as follows.
The issue is that the nfs ip address is hard-coded, which means if the IP if the nfs server change I need to commit a bunch of files.
Is there a way to get this value externally?
I understand that env_file can’t be set inside a volumes scope, so I am not sure how to do this with an env file for several docker-compoe files.
https://docs.docker.com/compose/environment-variables/#the-env-file Maybe the IP address could be a variable set in environment file?
I tried this locally in my own environment and it seems to be fine with variables substituted by actual values configured in .env file.
env_file will not help for variables outside the relevant service, but you can still use environment variables from the shell docker-compose is called, from the docs: “Compose uses the variable values from the shell environment in which docker-compose is run.”
Ok, so they can be set outside the docker-compose.yml. But then they have to still be set in .env which has to be in the same folder in the docker-compose.yml.
So I can’t really have a single point to update when the IP changed.
Its better though because .env is not committed.
Any ways to make those .env files take settings from a shared location?