I can't deploy with MUP because an error with docker/mongodb

March 1, 2018 1.1k views
Docker Deployment MongoDB Ubuntu
dtbarra
By:
dtbarra

I am trying to deploy a Meteor app using mup, and it is giving me all the time this error:

[xxx.xxx.xxx.xxx] x Start Mongo: FAILED

          ------------------------------------STDERR------------------------------------
          Error response from daemon: Container a1617b2aaaa3fd4aeb8e1241ec90ae32b4a88b0df9c95e5d73de608b68788ef0 is not running
    docker: Error response from daemon: driver failed programming external connectivity on endpoint mongodb (2f5db292f7022a39dfe3ff5fdf5ed7de38ddc7bb6f787625cd0fb45a5fa10cd6): Error starting userland proxy: listen tcp 127.0.0.1:27017: bind: address already in use.

          ------------------------------------STDOUT------------------------------------
          3.2.15: Pulling from library/mongo
    Digest: sha256:ef3277c7221e8512a1657ad90dfa2ad13ae2e35aacce6cd7defabbbdcf67ca76
    Status: Image is up to date for mongo:3.2.15
    mongodb
    mongodb
    Running mongo:3.2.15
    97a28fe9d2dca6130ffe6622e662a230ecea34214920673c574a4d3e57fafb3c

          ------------------------------------------------------------------------------

I have checked and I can connect through ssh to the server. I am using one of the One-click droplets from Digital Ocean because it came with Mongodb installed already. The version of Mongodb on the server is 3.4 and in my app I am using 3.2.15, I do not know if I should downgrade or upgrade either one or the other, or if even if the problem is there.

My mup.js file looks like this:

module.exports = {  servers: {
one: {
  host: 'xxx.xxx.xxx.xxx',
  username: 'root',
  pem: '~/.ssh/id_rsa'
  // or neither for authenticate from ssh-agent
}
},
meteor: {
name: 'myApp',
path: '../myApp/',

servers: {
  one: {},
},

buildOptions: {
  serverOnly: true,
},

env: {
  // If you are using ssl, it needs to start with https://
  ROOT_URL: 'http://app.com',
  "PORT": 80,
  MONGO_URL: 'mongodb://localhost/local',
  //MONGO_OPLOG_URL: 'mongodb://mongodb/local',
},
deployCheckWaitTime: 60,

docker: {
  // change to 'abernix/meteord:base' if your app is using Meteor 1.4 - 1.5
  image: 'abernix/meteord:base',
},

// Show progress bar while uploading bundle to server
// You might need to disable it on CI servers
enableUploadProgressBar: true
},

mongo: {
version: '3.2.15',
servers: {
  one: {}
}
},
};

I am going crazy with this, can someone help me please?

2 Answers
dtbarra March 2, 2018
Accepted Answer

Okey, I fixed it. The problem was that mup already sets up MongoDB for you, so using the one-click droplet with another MongoDB instance installed was messing it up. What I did was:
1- Create a ubuntu 14 Droplet, with a ssh key you already have created. If you do not have one just do in you client machine (chances are oit is gonna be your own computer):
ssh-keygen
Call the key as you want, but make sure you store it in ~/.ssh/
No passphrase needed
2- Connect using ssh from your computer and make sure you are doing so using the ssh key:
ssh root@droplet-ip-address
3- Run the following commands on the server (on the ssh connection you have just created):
sudo apt update
sudo apt upgrade
4- If you do not have npm or mup installed yet, run:
meteor npm install
npm install mup
npm update
5- Create a new deploy folder outside the project and run:
mup init
6- Your mup folder should look like:

module.exports = {
  servers: {
    one: {
      host: 'xxx.xxx.xxx.xxx',
      username: 'root',
      pem: '~/.ssh/id_rsa'
      //password: 'password'
      // or neither for authenticate from ssh-agent
    }
  },

  meteor: {
    name: 'appName',
    path: '../path_to_project/',

    servers: {
      one: {},
    },

    buildOptions: {
      serverOnly: true,
    },

    env: {
      // If you are using ssl, it needs to start with https://
      ROOT_URL: 'http://app.com',
      "PORT": 3000  ,
      MONGO_URL: 'mongodb://127.0.0.1:27017/admin', //<-- Remember to set it up using the port your database is using and the database name, in this case "27017" and "admin" respectively
    },
    deployCheckWaitTime: 60,

    docker: {
      // change to 'abernix/meteord:base' if your app is using Meteor 1.4 - 1.5
      image: 'abernix/meteord:base',
    },

    // Show progress bar while uploading bundle to server
    // You might need to disable it on CI servers
    enableUploadProgressBar: true
  },

  mongo: {
    version: '3.2.15', // Write the version you are using in your app, it does not matter what is on the server (mup and docker will take care of that fo you :D)
    servers: {
      one: {}
    }
  },
};

Now run:
mup setup
mup deploy

Enjoy your website! :D

docker: Error response from daemon: driver failed programming external connectivity on endpoint mongodb (2f5db292f7022a39dfe3ff5fdf5ed7de38ddc7bb6f787625cd0fb45a5fa10cd6): Error starting userland proxy: listen tcp 127.0.0.1:27017: bind: address already in use.

This makes it appear you have a mongod process already bound to the port you're trying to start the app on. Ensure you are not duplicating efforts.

  • But it is a fresh droplet and I haven't deployed anything yet. How can I stop the process bound to that port?

Have another answer? Share your knowledge.