title: MongoDB Docker init script
body: <p>I am attempting to seed my MongoDB in Docker.
  my docker-compose.yml file is pretty straight forward, here is my
  volume though:</p>
  <pre><code>...
  volumes:
        - ./mongo/init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro
        - ./mongo/mongod.conf:/etc/mongod.conf:ro
        - ./mongo/mongo-volume:/data/db
  ...
  </code></pre>
  <p>I have init-mongo.js mapped as a volume, here is its contents:</p>
  <pre><code>db.createUser({
    user: 'root',
    pwd: 'toor',
    roles: [
      {
        role: 'readWrite',
        db: 'testDB',
      },
    ],
  });
  db.createCollection('users', { capped: false });
  db.createCollection('test', { capped: false });
  
  db.test.insert([
    { &quot;item&quot;: 1 },
    { &quot;item&quot;: 2 },
    { &quot;item&quot;: 3 },
    { &quot;item&quot;: 4 },
    { &quot;item&quot;: 5 }
  ]);
  </code></pre>
  <p>The user <code>root</code> and the database <code>testDB</code> as well as the collections <code>users</code> and <code>test</code> are all created with no problem.</p>
  <p>The issue is that <code>db.test.insert([])</code> seems to be missed all together, and NO documents are inserted into the <code>test</code> collection.</p>
  <p>Any Ideas why that is?
  I would absolutely love to get this working and would really appreciate any assistance with this.</p>
  <p>Thanks,
  -Kevin</p>