Hi Chris, Thanks for the reply.
May i see you replica set initialization? Do we need to update /etc/hosts file for each client where we try to connect to replica set? I did update my hosts file but still I couldn’t connect from remote client.
In my case, I do the following
config={"_id":"rs0","members":[{"_id":0,"host":"mongo1:27017","priority":2},{"_id":1,"host":"mongo2:27017"},{"_id":2,"host":"mongo3:27017"}]}
I followed your compose file, everything is working fine from the machine where my docker is running. I still get the same error from remote client.
I see that you didn’t use any ip_binding in your compose file, how does it work for you from remote clients? according MongoDB documentation we should either use 0.0.0.0 or ip_address or host-names of client right?
Please correct me if i am wrong.
I get the following error when connecting from remote client
connecting to: mongodb://127.0.10.1:27017/?compressors=disabled&gssapiServiceName=mongodb&replicaSet=rs0
{"t":{"$date":"2021-01-10T07:24:31.441Z"},"s":"I", "c":"NETWORK", "id":4333208, "ctx":"ReplicaSetMonitor-TaskExecutor","msg":"RSM host selection timeout","attr":{"replicaSet":"rs0","error":"FailedToSatisfyReadPreference: Could not find host matching read preference { mode: \"nearest\" } for set rs0"}}
Error: connect failed to replica set rs0/127.0.10.1:27017 :
connect@src/mongo/shell/mongo.js:374:17
I completely started with new configuration, was deleted previous /data/db folder and my mongo volumes just to make sure if it wasn’t related to any configuration problem.
Thanks