Running a MongoDB Replica Set on Docker 1.12 Swarm Mode: Step by Step
Blake Mitchell
1497

Hello Mr. Blake,

First thank you very much for writing such beautiful walkthrough to create mongodb cluster in docker swarm.

While trying to create cluster in docker swarm running on different physical machines, i face an issue.

On running following command

`docker exec -it $(docker ps -qf label=com.docker.swarm.service.name=mongo1) mongo — eval ‘rs.initiate({ _id: “example”, members: [{ _id: 1, host: “mongo1:27017” }, { _id: 2, host: “mongo2:27017” }, { _id: 3, host: “mongo3:27017” }], settings: { getLastErrorDefaults: { w: “majority”, wtimeout: 30000 }}})’`

I get error: `{

“ok” : 0,

“errmsg” : “replSetInitiate quorum check failed because not all proposed set members responded affirmatively: mongo2:27017 failed with Couldn’t get a connection within the time limit, mongo3:27017 failed with Couldn’t get a connection within the time limit”,

“code” : 74,

“codeName” : “NodeNotFound”

}`

It seems like containers are unable to connect to each other. can you please help me here?

Show your support

Clapping shows how much you appreciated Muhammad Nadeem Azam’s story.