title: Docker + Mongodb: Initiating replicaset inside Dockerfile
body: <p>I need to create a Dockerfile starting mongodb and initiating replicaset after that.</p>
  
  <p>First I created a Dockefile as below:</p>
  
  <pre><code>FROM mongo:latest 
  EXPOSE 27017 
  ADD setup.sh /root/setup.sh 
  CMD ["bash","/root/setup.sh"] 
  </code></pre>
  
  <p>Then I created the setup.sh file like this:</p>
  
  <pre><code>#!/bin/bash 
  mongod --fork --replSet rs0 --noprealloc --smallfiles 
  sleep 5 
  mongo --eval "rs.initiate()"
  </code></pre>
  
  <p>The problem is that it´s not working, am I doing something wrong?</p>
  
  <p>Thanks!</p>