title: How to create a DB for MongoDB container on start up?
body: <p>I am working with Docker and I have a stack with PHP, MySQL, Apache and Redis. I need to add MongoDB now so I was checking the <a href="https://github.com/docker-library/mongo/blob/4a81205a13fefc418355248f750551e4f7c62361/3.4/Dockerfile" rel="noreferrer">Dockerfile</a> for the latest version and also <a href="https://github.com/docker-library/mongo/blob/4a81205a13fefc418355248f750551e4f7c62361/3.4/docker-entrypoint.sh" rel="noreferrer">the docker-entrypoint.sh</a> file from the <a href="https://hub.docker.com/r/library/mongo/" rel="noreferrer">MongoDB Dockerhub</a> but I couldn't find a way to setup a default DB, admin user/password and possibly auth method for the container from a <code>docker-compose.yml</code> file.</p>
  
  <p>In MySQL you can setup some ENV variables as for example:</p>
  
  <pre><code>db:
      image: mysql:5.7
      env_file: .env
      environment:
        MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
        MYSQL_DATABASE: ${MYSQL_DATABASE}
        MYSQL_USER: ${MYSQL_USER}
        MYSQL_PASSWORD: ${MYSQL_PASSWORD}
  </code></pre>
  
  <p>And this will setup the DB and the user/password as the <code>root</code> password. </p>
  
  <p>Is there any way to achieve the same with MongoDB? Anyone has some experience or workaround?</p>