Docker Hub official Nginx image configuration problem

  docker, question

Docker Hub official Nginx mirror document
Follow the documentation to configure, some questions don’t know what it means.
Original quote:

using environment variables in nginx configuration

Out-of-the-box, Nginx doesn’t support using environment variables inside most configuration blocks. Butenvsubstmay 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
 - ./mysite.template:/etc/nginx/conf.d/mysite.template
 - "8080:80"
 /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 :

listen ${NGINX_PORT};

In the last line of the code section, that iscommand:In that line,
1、envsubstWhat is the function?
2、daemon off;What is the function?
3、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.
Command isdocker 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