How does dockerfile define a variable profile?

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


this is generally placed in .env, but not in Dockerfile


https://github.com/laradock/l.


the configuration file must not be migrated to the image, the configuration file is still mounted or the environment variables are passed in or command line parameters are used. It is recommended that configmap in kubernetes is a reasonable way of configuration management.

Menu