I'm using Sails 0.12.3 and mongo 3.2.7
Here's my config/connections.js.
mongo: {
adapter: 'sails-mongo',
host: 'database',
port: 27017,
user: 'user', //optional
password: 'password', //optional
database: 'db' //optional
}
and my docker-compose.yml
version: '2'
services:
myservice:
//blabla
links:
- database
database:
image: 'mongo:latest'
container_name: 'database'
environment:
MONGODB_PASSWORD: "password"
MONGODB_USER: "user"
MONGODB_DATABASE: "db"
The problem comes whenever I build the containers with docker-compose up --build, the error comes from the sails-mongo
module.
error: A hook (`orm`) failed to load!
error: Error: Failed to connect to MongoDB. Are you sure your configured Mongo instance is running?
Error details:
{ MongoError: Authentication failed.
at Function.MongoError.create (/app/node_modules/mongodb-core/lib/error.js:31:11)
at commandCallback (/app/node_modules/mongodb-core/lib/topologies/server.js:929:66)
at Callbacks.emit (/app/node_modules/mongodb-core/lib/topologies/server.js:116:3)
at .messageHandler (/app/node_modules/mongodb-core/lib/topologies/server.js:282:23)
at Socket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:273:22)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:172:18)
at Socket.Readable.push (_stream_readable.js:130:10)
at TCP.onread (net.js:542:20)
name: 'MongoError',
message: 'Authentication failed.',
ok: 0,
code: 18,
errmsg: 'Authentication failed.' }
Is there any extra configuration I need to just run the containers? I understand that Mongo doesn't create a database unless there's some data to store but I'm not sure if this is related at all.