title: Connect to host mongodb from docker container
body: <p>So I want to connect to my mongodb running on my host machine (DO droplet, Ubuntu 16.04). It is running on the default <code>27017</code> port on localhost.</p>
  
  <p>I then use <a href="https://github.com/zodern/meteor-up" rel="noreferrer">mup</a> to deploy my Meteor app on my DO droplet, which is using docker to run my Meteor app inside a container. So far so good.
  A standard <code>mongodb://...</code> connection url is used to connect the app to the mongodb.
  Now I have the following problem:</p>
  
  <p><code>mongodb://...@localhost:27017...</code> obviously does not work inside the docker container, as <code>localhost</code> is not the host's localhost.</p>
  
  <p>I already read many stackoverflow posts on this, I already tried using:</p>
  
  <ul>
  <li><code>--network="host"</code> - did not work as it said <code>0.0.0.0:80</code> is already in use or something like that (nginx proxy)</li>
  <li><code>--add-host="local:&lt;MY-DROPLET-INTERNET-IP&gt;"</code> and connect via <code>mongodb://...@local:27017...</code>: also not working as I can access my mongodb only from localhost, not from the public IP</li>
  </ul>
  
  <p>This has to be a common problem!</p>
  
  <p><strong>tl;dr</strong> - What is the proper way to expose the hosts <code>localhost</code> inside a docker container so I can connect to services running on the host? (including their ports, e.g. 27017).</p>
  
  <p>I hope someone can help!</p>