title: Can't start mongo with docker command, but can with /bin/bash inside container (with data volume)
body: <p>This <code>docker-compose.yml</code>:</p>
  
  <pre><code>services:
    database:
      image: mongo:3.2
      ports:
        - "27017"
      command: "mongod --dbpath=/usr/database"
      networks:
        - backend
      volumes:
        - dbdata:/usr/database
  
  volumes:
    dbdata:
  </code></pre>
  
  <p>results in this error (snipped):</p>
  
  <pre><code>database_1  | 2016-11-28T06:30:29.864+0000 I STORAGE  [initandlisten] exception in initAndListen: 98 Unable to create/open lock file: /usr/database/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
  </code></pre>
  
  <p>Ditto for just trying to run the command in a container using that image directly:</p>
  
  <pre><code>$ docker run -v /usr/database mongo:3.2 mongod --dbpath=/usr/database
  </code></pre>
  
  <p>But, if I run <code>/bin/bash</code> when starting the container, and THEN start <code>mongo</code>, we're OK:</p>
  
  <pre><code>$ docker run -it -v /usr/database mongo:3.2 /bin/bash
  root@8aab722fad89:/# mongod --dbpath=/usr/database
  </code></pre>
  
  <p>Based on the output, the difference seems to be that in the second scenario, the command is run as root.</p>
  
  <p>So, my questions are:</p>
  
  <ol>
  <li>Why does the <code>/bin/bash</code> method work, when the others do not?</li>
  <li>How can I replicate that reason, in the docker-compose?</li>
  </ol>
  
  <p>Note: On OSX, since that seems to effect whether you can mount a host directory as a volume for Mongo to use - not that I'm doing that.</p>