Reputation: 10049
This should be really simple but I can't find any answer I installed docker on a server I am running mongo on it
docker run --name some-mongo -d mongo
I have one user
$ docker exec -it some-mongo mongo admin
connecting to: admin
> db.createUser({ user: 'jsmith', pwd: 'some-initial-password', roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] });
Successfully added user: {
"user" : "jsmith",
"roles" : [
{
"role" : "userAdminAnyDatabase",
"db" : "admin"
}
]
}
And when I am trying to connect from an other server
mongo my-server.com:27017/admin -u jsmith -p some-initial-password
I have
MongoDB shell version: 3.2.0
connecting to: infra1.host.com:27017/admin
2016-08-01T19:06:08.409+0100 W NETWORK [thread1] Failed to connect to 54.93.113.11:27017, reason: errno:61 Connection refused
2016-08-01T19:06:08.410+0100 E QUERY [thread1] Error: couldn't connect to server my-server.com:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:226:14
@(connect):1:6
Upvotes: 0
Views: 2700
Reputation: 8721
Just redirect mongo port:
docker run --name some-mongo -p 27017:27017 -d mongo
Upvotes: 3