The Docker environment variable problem, for example, downloaded a nginx image on Docker Hub. Now I want to use my own configuration file. See that there are three ways:
1. Transfer configuration with environment variables.
2. Use the data volume to place the configuration files in the data volume.
3. Modify the mirror image and save it as a new one.
Now, I want to adoptType 1Methods, documentation onEnvironmental variableThe contents of the report are as follows:
But how to configure it is still a little unclear.
Who told you that environment variables can be used to transfer configuration files …
Environmental variables can be used to mean that some software can recognize not only the configuration provided in environmental variables but also the configuration in file form.Unfortunately, Nginx is not included.
Take wget as an example. When setting up HTTP proxy, you can choose one of the following methods:
Add a line to the configuration file
http_proxy = http://example.com/xxx
The system environment variables
The effect of the two methods is the same.
Of course, you can write a Shell script in the Docker container to modify the contents of the configuration file according to the environment variables, but this is another topic. Github has many tools to implement similar functions, such asTiller.