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.

  • Configuring docker container with ansible
  • docker—run nginx not allways working
  • Force a problematic docker container to restart itself?
  • Simple docker command does not work: x509: cannot validate certificate
  • Permission Issue with Docker Volume Driver for Azure File Storage
  • Best way to extend Dockerfile to pull deps/env vars from common/shared repositories
  • 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
    
    };
    

  • How can I access a shell on the VM Linux host when using the Docker Windows Beta
  • Is Docker slow when using device mapper on Fedora?
  • nginx in docker how to disable http redirects to https
  • Error Pulling private docker repository from mac Boot2Docker
  • Ubuntu based docker-machine image
  • Docker remove all images permission denied
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.