Unable to connect to mongos router (Docker).

117 views
Skip to first unread message

SoS

unread,
May 23, 2016, 6:01:25 PM5/23/16
to mongodb-user
Hi guys,

I'm following the below guide for trying to set up a MongoDB shard on Docker and I'm finding some issues.

I just created the router container but i'm unable to connect for initializing the previously created shard, for some reason.

[root@centos7 ~]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                      NAMES
93a2d3b131ab        dev24/mongos        "usr/bin/mongos --por"   5 seconds ago       Up 3 seconds        0.0.0.0:32778->27017/tcp   mongos1
c06fb11f356c        dev24/mongod        "usr/bin/mongod --nop"   About an hour ago   Up About an hour    0.0.0.0:32771->27017/tcp   cfg1
28314d2a97d1        dev24/mongod        "usr/bin/mongod --rep"   About an hour ago   Up About an hour    0.0.0.0:32770->27017/tcp   rs1_srv3
59f9346bbe34        dev24/mongod        "usr/bin/mongod --rep"   About an hour ago   Up About an hour    0.0.0.0:32769->27017/tcp   rs1_srv2
99451163f0b2        dev24/mongod        "usr/bin/mongod --rep"   About an hour ago   Up About an hour    0.0.0.0:32768->27017/tcp   rs1_srv1


[root@centos7 ~]# docker inspect mongos1 |grep -i hostport
                    "HostPort": "32778"


[root@centos7 ~]# mongo --port 127:0:0.1:32778
MongoDB shell version: 2.6.11
connecting to: 127.0.0.1:127:0:0.1:32778/test
2016-05-23T17:28:07.173+0100 getaddrinfo("127.0.0.1:127:0:0.1") failed: Name or service not known
2016-05-23T17:28:07.174+0100 Error: couldn't connect to server 127.0.0.1:127:0:0.1:32778 (0.0.0.0), address resolved to 0.0.0.0 at src/mongo/shell/mongo.js:148
exception: connect failed


Any pointers?

Thanks.



Kevin Adistambha

unread,
May 31, 2016, 8:49:17 PM5/31/16
to mongodb-user

Hi,

I’m following the below guide for trying to set up a MongoDB shard on Docker and I’m finding some issues.

Which guide are you following? Please note that the mongo image on Docker Hub is officially maintained by the Docker team and is not directly supported by MongoDB. For Docker-specific support I would suggest posting on Docker Forums.

Regarding your connection issue:

[root@centos7 ~]# mongo —port 127:0:0.1:32778

You are supplying an invalid --port parameter. I think you meant to connect to 127.0.0.1 on port 32778. Could you try to change the command line to

mongo --host 127.0.0.1 --port 32778

and see if you can connect to it?

If you’re still having issues, could you post:

  • the MongoDB version you are using
  • the guide you are using to set up your deployment
  • the commands you used to start the containers

Best regards,
Kevin

Reply all
Reply to author
Forward
0 new messages