title: Mongodb docker container with client access control
body: <p>I want to create a docker container with a mongodb configured with client access control (user authentication, see <a href="https://docs.mongodb.org/v3.0/tutorial/enable-authentication/" rel="nofollow">this</a>).</p>
  
  <p>I have successfully configured a docker container with mongo using <a href="https://hub.docker.com/_/mongo/" rel="nofollow">this image</a>. But it doesn't use mongo access control.</p>
  
  <p>The problem is that to enable access control I have to run mongodb with a specific command line (<code>--auth</code>) but only after creating the first admin user.</p>
  
  <p>With a standard mongodb installation I normally perform these steps:</p>
  
  <ul>
  <li>run mongod without <code>--auth</code></li>
  <li>connect to mongo and add the admin user</li>
  <li>restart mongo with <code>--auth</code></li>
  </ul>
  
  <p>How I'm supposed to do it with docker? Because mongo image always start without <code>--auth</code>. Should I create a new image? Or maybe modify the entry point?</p>
  
  <p>Probably I'm missing something, I'm new to docker...</p>