title: docker-compose to run django with mongodb
body: <p>I am facing problem using docker-compose to link a django container with postgres and mongo containers? I am trying to use "docker-compose up" which starts up the mongo and postgres containers (as I need to link both) but still the django app is not able to connect to mongodb on default settings. My django-compose.yml file contents are copied below:</p>
  
  <pre><code>    db1:
        image: postgres
      db2:
        image: mongo
        ports:
          - "27017:27017"
      web:
        build: .
        command: python manage.py runserver 0.0.0.0:8000
        volumes:
          - .:/code
        ports:
          - "8000:8000"
        links:
          - db1
          - db2
  </code></pre>
  
  <p>It does connect with postgres with default settings. I can also telnet to the mongodb port locally. Still, I get this error on starting the web container:</p>
  
  <blockquote>
    <p>File
    "/usr/local/lib/python2.7/site-packages/mongoengine/connection.py",
    line 124, in get_connection web_1 | raise ConnectionError("Cannot
    connect to database %s :\n%s" % (alias, e)) web_1 |
    mongoengine.connection.ConnectionError: Cannot connect to database
    default : web_1 | [Errno 111] Connection refused</p>
  </blockquote>
  
  <p>PS: I had successfully started a django-postgres connected app on my localhost, but it failed connecting to db, on an AWS instance. That is another problem I still need to get to root of.</p>