Docker Hub official Nginx mirror document
Follow the documentation to configure, some questions don’t know what it means.
using environment variables in nginx configuration
Out-of-the-box, Nginx doesn’t support using environment variables inside most configuration blocks. But
envsubstmay be used as a workaround if you need to generate your nginx configuration dynamically before nginx starts.
Here is an example using docker-compose.yml:
image: nginx volumes: - ./mysite.template:/etc/nginx/conf.d/mysite.template ports: - "8080:80" environment: - NGINX_HOST=foobar.com - NGINX_PORT=80 command: /bin/bash -c "envsubst < /etc/nginx/conf.d/mysite.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;' "
The mysite.template file may then contain variable references like this :
In the last line of the code section, that is
command：In that line,
envsubstWhat is the function?
daemon off;What is the function?
command：What does the order itself mean? When will the following orders be executed?
Envsubst is probably something that operates environment variables.For details, see the instruction
Daemon off: is a parameter of nginx, indicating the method of not starting in the background.
docker run nginx /bin/shIn the mirror name nginx after the section /bin/sh, can execute any command
It seems that you said it in another post