I have meteor application with file mup.js
. And port of mongo database is set equally to 27018.
module.exports = {
servers: {
...
},
meteor: {
...
env: {
PORT: 3000,
ROOT_URL: 'http://app.com',
MONGO_URL: 'mongodb://localhost:27018/meteor',
},
docker: {
image: 'abernix/meteord:base',
imagePort: 9090, // (default: 80, some images EXPOSE different ports)
},
...
},
mongo: {
port: 27018,
version: '3.4.1',
servers: {
...
}
}
};
I want to have mongo on port 27018, because on server there is mongo on port 27017. But When I type:
mup setup
I obtain:
-----------------------------------STDERR-----------------------------------
Error response from daemon: Container
bb3277bc8eb71f7dc943bee81b429e0ff0343e5905f6695ed2c7cad2b562317f is not
running docker: Error response from daemon: driver failed programming
external connectivity on endpoint mongodb
(fd60247139585238bfa24a42d2fd6221c08e2d2a053d4d03ffedbbab5604fd9a): Error
starting userland proxy: listen tcp 127.0.0.1:27017: bind: address already in
use.
-----------------------------------STDOUT-----------------------------------
3.4.1: Pulling from library/mongo Digest:
sha256:aff0c497cff4f116583b99b21775a8844a17bcf5c69f7f3f6028013bf0d6c00c
Status: Image is up to date for mongo:3.4.1 mongodb mongodb
Running mongo:3.4.1
7dcf91a6f136d85a884323c0a1230a673d8f25a9197dc85738e44e30139c6035
----------------------------------------------------------------------------
How to ensure using port 27018 instead of 27017?
There is an issue in the Meteor github related to what you want to do. Unfortunately the embedded mongo port doesn't seem to be configurable yet. If you set the MONGO_URL environment variable, Meteor will NOT start an instance of mongo, it will just try to connect to the given url.
If you want mongo to spin up an instance of mongo for you, it would do it on the default port, which is the meteor port + 1.
From the meteor help run
documentation:
--port, -p Port to listen on (instead of the default 3000). Also uses port N+1 and a port specified by --app-port. Specify as --port=host:port to bind to a specific interface.
So if you run the meteor app on the default (3000) port, you would have a mongo instance on 3001.
Your only other option, if you need to have a mongo instance on a specific port, is to deploy the database separately. Here is some documentation on how to dockerize your mongo deployment: https://docs.docker.com/engine/examples/mongodb/
With some work, you could write a dockerfile which your mup can use to deploy both a mongo instance and your app.
Hope that helps.