title: How to connect nodeJS docker container to mongoDB
body: <p>I have problems to connect a nodeJS application which is running as a docker container to a mongoDB. Let me explain what I have done so far:</p>
  
  <pre><code>$ docker ps
  
  CONTAINER ID    IMAGE        COMMAND                  CREATED        STATUS        PORTS        NAMES
  3a3732cc1d90    mongo:3.4    "docker-entrypoint..."   3 weeks ago    Up 3 weeks    27017/tcp    mongo_live
  </code></pre>
  
  <p>As you can see, there is already a mongo docker container running.</p>
  
  <p>Now I'm running my nodeJS application docker container (which is a build from meteorJS):</p>
  
  <pre><code>$ docker run -it 0b422defbd59 /bin/bash
  </code></pre>
  
  <p>In this docker container I want to run the application by running:</p>
  
  <pre><code>$ node main.js
  </code></pre>
  
  <p>Now I'm getting the error</p>
  
  <pre><code>Error: MONGO_URL must be set in environment
  </code></pre>
  
  <p>I already tried to set MONGO_URL by setting:</p>
  
  <pre><code>ENV MONGO_URL mongodb://mongo_live:27017/
  </code></pre>
  
  <p>But this doesn't work:</p>
  
  <pre><code>MongoError: failed to connect to server [mongo_live:27017] on first connect
  </code></pre>
  
  <p>So my question is how to connect to a DB, which is - as far as I understand - 'outside' of the running container. Alternativly how do I set up a new DB to this container?</p>