Use the code from here https://github.com/docker-library/docs/tree/master/nginx#using-environment-variables-in-nginx-configuration
command: /bin/bash -c "envsubst < /etc/nginx/conf.d/mysite.template > /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'"
Got the error,
ERROR: for xxx_1 Cannot start service xxx: OCI runtime create failed: container_linux.go:344: starting container process caused "exec: "/bin/bash": stat /bin/bash: no such file or directory": unknown
ERROR: for xxx Cannot start service xxx: OCI runtime create failed: container_linux.go:344: starting container process caused "exec: "/bin/bash": stat /bin/bash: no such file or directory": unknown
ERROR: Encountered errors while bringing up the project.
Change /bin/bash to /bin/sh then works.
But why ?