Unable to run mongo container with replica set using docker-compose

前端 未结 2 1748
野性不改
野性不改 2021-01-24 09:15

Here\'s my docker-compose file:

version: \'3\'
services:

  mongo:
    hostname: mongo
    container_name: search_mongo
    image: mongo:latest
    volumes:
             


        
2条回答
  •  佛祖请我去吃肉
    2021-01-24 09:56

    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.

提交回复
热议问题