How does dockerfile define variable configuration files?

  docker, question

For example, there is a business program, which has a Conf file with some configuration of service ip and database address. how can it be specified when running the container? Is it necessary to have a single configuration file and then copy the new configuration file in when the container is running?

I now know that one way to do this is (take python for example)
Write a python script to run in Dockerfile, which requires a mirrored environment to support python
The main content is to use OS. environment to obtain environment variables (assuming MYVAR)
Then change the corresponding parameter to be modified in the configuration file to {var} with double brackets.
Then, for example, osdict = os.environ
Myvar = os.dict.get(‘MYVAR’, default)
With open as fp:

Use the format method to format var=myvar

This is usually placed in. env, not in Dockerfile.