for example, if there is a business program that has a Conf file with some configuration of the service ip, database address, how can it be specified when running the container? Or do you have to have a separate configuration file and then copy the new configuration file when you run the container?
I now know that one way to do this is to (take python as an example)
write a python script and run it in Dockerfile, so that the environment that needs to be mirrored supports python
. The main content is, Use os.environ to get the environment variable (assuming MYVAR)
, and then change the parameter in the configuration file to {var} plus double parentheses
and then such as osdict = os.environ
myvar = os.dict.get ("MYVAR", default)
with open (configuration file) as fp:
formatvar=myvar