title: Mongo docker - Dockerfile with indexCreate
body: <p>I've got following problem:
  Need to create mongodb docker image with some initial data and config, so I started writing Dockerfile:</p>
  
  <p>Dockerfile:</p>
  
  <pre><code>FROM mongo:latest
  EXPOSE 27017
  ADD ./scripts /scripts
  RUN mongo PBM /scripts/indexes
  </code></pre>
  
  <p>/scripts/indexes:</p>
  
  <pre><code>db.events.createIndex( {'x1':1}, {expireAfterSeconds: 0})
  </code></pre>
  
  <p>And here I've occured  first error, that I cannot connect to db:</p>
  
  <pre><code>Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
  </code></pre>
  
  <p>Any ideas ?</p>
  
  <p><strong>SOLUTION</strong></p>
  
  <p>need to use ENTRYPOINT against RUN, because when using the second one, db does not exist.</p>