I want to run a script, right after running
`docker-compose up -d`
Here is my snippet of docker-compose.yml
. The other settings are mysql server, redis...etc....but they are not causing any problems
web:
image: nginx
container_name: web-project
volumes:
- ./code:/srv
working_dir: /srv/myweb
extra_hosts:
- "myweb.local:127.0.0.1"
ports:
- 8081:80
# tty: true
command: sh /srv/scripts/post-run-web.sh
So whenever i run docker-compose up -d
or docker-compose up
It all stops. (the containers do not keep running). Although my shell script is simple (running echos...or phpunit). Here is my script.
#!/bin/bash
echo running post install scripts for web..;
cd /srv/myweb
npm install
composer self-update
composer update
And this is the error I get. It is like the server (nginx) is not running yet. Also if I connect to the server using exec bash, and i check out the processes. I do not see nginx running (yet).
web_1 | You are already using composer version 7a9eb02190d334513e99a479510f87eed18cf958.
web_1 | Loading composer repositories with package information
web_1 | Updating dependencies (including require-dev)
web_1 | Generating autoload files
web-project exited with code 0
Gracefully stopping... (press Ctrl+C again to force)
Stopping mysql-project... done
Stopping rabbitmq-project... done
Stopping redis-project... done
So why is it exiting, although the script is syntax-wise correct? How can i make it run correctly? (what am I doing, setting up wrong!)