Here\'s my docker-compose file:
version: \'3\'
services:
mongo:
hostname: mongo
container_name: search_mongo
image: mongo:latest
volumes:
If your last command at the script will never exit (i.e. stop running), your container keeps running. So, while (true);do sleep 1; done
is one fix.
If you want to have solution where you can close container when wanted, you can use something like
while (! test -e /tmp/stop); do sleep 1; done; rm /tmp/stop
So, when you say at command line touch /tmp/stop
, it will stop that loop what keeps container running.
Your startup script should not initialise or monitor the replicaset; those should be manual tasks.
You should bear in mind that:
I strongly recommend that you make three changes: