I am using following command in docker-compose to copy environment values into nginx configuration file at startup of nginx container.
command: /bin/sh -c "envsubst < /etc/nginx/conf.d/site.template > /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'"
I want to get rid of docker-compose and use it with the docker run. I tried to inlcude the command in Dockerfile and use CMD. But the ngix container immediately exit.
FROM mydocker:latest
COPY ./site.template /etc/nginx/conf.d/site.template
CMD envsubst < /etc/nginx/conf.d/site.template > /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'
Can someone please help me here. Thanks in advance