Hello!
Sorry, I have tried to find an answer to this, but have not had much luck.
I have a self-hosted MongoDB Replica-set, and it has been working very well. But I would like to have additional safty by adding MongoDB Atlas into my replica-set. It would be great to have my primary still on the self hosted boxes.
I have this docker-compose:
services:
mongo1:
hostname: mongo1
image: mongo
expose:
- 27017
ports:
- 30001:27017
restart: always
networks:
- mongo
command: mongod --replSet my-mongo-set
mongo2:
hostname: mongo2
image: mongo
expose:
- 27017
ports:
- 30002:27017
restart: always
networks:
- mongo
command: mongod --replSet my-mongo-set
mongo3:
hostname: mongo3
image: mongo
expose:
- 27017
ports:
- 30003:27017
restart: always
networks:
- mongo
command: mongod --replSet my-mongo-set
# finally, we can define the initialization server
# this runs the `rs.initiate` command to intialize
# the replica set and connect the three servers to each other
mongoinit:
image: mongo
# this container will exit after executing the command
restart: "no"
networks:
- mongo
depends_on:
- mongo1
- mongo2
- mongo3
command: >
mongo --host mongo1:27017 --eval
'
db = (new Mongo("mongo1:27017")).getDB("CropWatch");
config = {
"_id" : "my-mongo-set",
"members" : [
{
"_id" : 0,
"host" : "mongo1:27017"
},
{
"_id" : 1,
"host" : "mongo2:27017"
},
{
"_id" : 2,
"host" : "mongo3:27017"
}
]
};
rs.initiate(config);
'
networks:
mongo:
driver: bridge
This works, well, but I am hoping to add Atlas into the “members” list.
The problem is that this never seems to work.
Has anyone tried this? Succeeded?
Thanks for the help!!!
-Kevin