docker-compose yml running a script after up

command overrides the default command.

That’s the reason your container stops: nginx never starts.

At the end of your script you have to run nginx


echo running post install scripts for web..;
cd /srv/myweb
npm install
composer self-update
composer update

By the way, I suggest you to change your script and run npm install and composer *update only if required (thus only if some file in /src/myweb does not exists), because it makes your container startup time increase in vain.

Note that by doing so, NginX will never catch the SIGTERM signal sent by docker stop. That can cause it to be abruptly killed.

Instead, if you want to be sure that SIGTERM is received by nginx, you have to replace the last line with exec nginx. This replaces the bash process with nginx itself.

Leave a Comment