title: How does docker-compose link work?
body: <p>I have three containers, web, rest and db. I want rest (nodejs) to be able to access db (mongodb).</p>
  
  <p>My docker-compose.yml:</p>
  
  <pre><code>version: '2'
  services:
   web:
    build: front
    depends_on:
     - db
     - rest
   db:
    build: backend/mongodb
    volumes:
     - /src/docker/mongodb:/var/lib/mongodb
    restart: always
   rest:
    build: backend/rest
    restart: always
    links:
      - db:database
  </code></pre>
  
  <p>In my nodejs program:</p>
  
  <pre><code>MongoClient.connect("mongodb://database:27017/mytest", function (err, db) {
   ...
  </code></pre>
  
  <p>However, my mongo client can't reach the database and keeps restarting...</p>
  
  <p>What am I doing wrong?</p>