title: Unable to run mongo container with replica set using docker-compose
body: <p>Here's my docker-compose file:</p>
  
  <pre><code>version: '3'
  services:
  
    mongo:
      hostname: mongo
      container_name: search_mongo
      image: mongo:latest
      volumes:
        - ./docker/local/persist/mongo:/data/db
        - ./docker/mongo:/opt/mongo
      ports:
        - "8884:27017"
        - "8885:27018"
      entrypoint: /opt/mongo/entrypoint_mongo.sh
  
    agent:
      build: .
      image: myapp_search:compose
      depends_on:
        - mongo
  </code></pre>
  
  <p>Here's my entrypoint_mongo.sh</p>
  
  <pre><code>#!/bin/bash
  mongod --port 27018 --replSet rs0 --fork --syslog --smallfiles
  mongo --port 27018 --eval "rs.initiate({_id : 'rs0', members : [{_id : 0, host : 'mongo:27018'}]})"
  mongo --port 27018 --eval "while(true) {if (rs.status().ok) break;sleep(1000)};"
  </code></pre>
  
  <p>The issue I am facing is :
  The mongo container is executing all its steps successfully but its exiting with status 0.</p>
  
  <pre><code>mongo_1          | about to fork child process, waiting until server is ready for connections.
  mongo_1          | forked process: 7
  mongo_1          | child process started successfully, parent exiting
  mongo_1          | MongoDB shell version v3.4.10
  mongo_1          | connecting to: mongodb://127.0.0.1:27018/
  mongo_1          | MongoDB server version: 3.4.10
  mongo_1          | { "ok" : 1 }
  mongo_1          | MongoDB shell version v3.4.10
  mongo_1          | connecting to: mongodb://127.0.0.1:27018/
  mongo_1          | MongoDB server version: 3.4.10
  search_mongo exited with code 0
  </code></pre>