node.js in a dockerfile cant connect to mongolabs via mongoose: getaddrinfo ESRCH

I have done some googling but haven’t found anything..

My setup is like this:
OS X, boot2docker, everything local except mongolabs database.

  • cant start docker after installation on linux
  • How to create a shared volume between docker host and container in Mac
  • Jenkins: running build does not provision docker slave
  • What is image “containersol/minimesos” in minimesos?
  • How to run Consul on docker with initial key-value pair data?
  • Docker: How to connect to Postgresql container without exposing port
  • The project is working fine when it’s not inside docker.

    I am trying to run my nodejs project inside a docker image. I have done this before, but not with a database connection requirement. The problem is that my node app crashes on startup with the information:

    /src/node_modules/mongoose/node_modules/mongodb/lib/server.js:228
        process.nextTick(function() { throw err; })
                                                    ^
        Error: getaddrinfo ESRCH
            at errnoException (dns.js:37:11)
            at Object.onanswer [as oncomplete] (dns.js:124:16)
    

    Does anyone have any idea how to solve this? Is there a DNS flag inside docker that can be set or is anything blocking my connection to the outside?

    EDIT:

    I connect to my mongodb on mongolabs through mongoose.

    var configDB = require('./config/database.js');    
    mongoose.connect(configDB.url);
    

    and my passport.js file looks like this:

    module.exports = {
    
        'url' : 'mongodb://<user>:<password>@ds045027.mongolab.com:45027/database
    
    };
    

  • docker internet connectivity with iptables=false
  • how does an app within a docker container access database hosted on another server which is in the same LAN
  • /proc/partitions within container not as expected
  • Find opened sockets in docker container
  • Is there a good reason for setting up virtualenv for python in Docker containers?
  • Mount remote machine directory to its container with docker-machine on windows
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.