title: Connecting to mongo docker container from host
body: <p>I'm running Docker on OS X with:</p>
  
  <pre><code>docker run --name mongo -p 27017:27017 -v ./data/db:/data/db -d mongo mongod
  </code></pre>
  
  <p>and using the ip I get from:</p>
  
  <pre><code>docker inspect --format '{{ .NetworkSettings.IPAddress }}' &lt;cid&gt;
  </code></pre>
  
  <p>in:</p>
  
  <pre><code>var MongoClient = require('mongodb').MongoClient;
  var assert = require('assert');
  var url = 'mongodb://&lt;ip&gt;:27017';
  
  MongoClient.connect(url, function(err, db) {
     assert.equal(null, err);
     db.close();
  });
  </code></pre>
  
  <p>and I'm getting a timed out error. </p>
  
  <p>I'm using the official mongo repository from Docker Hub. Is there any additional setup that I need to do in order to connect from the host?</p>