Im wondering as to how to start a mongodb replica set using the new Docker 1.12 swarm mode service model. starting a service allows you to specify a number of container replicas, which in the minimal replica set case would be 3. but how would then parameters be specified for the replica set primary, if Docker runs individual containers itself, all with the same name of the service (for contacting the containers over the overlay network)?
how would the replica-set containers be contacting each other with different names? mongodb1,mongodb2,mongodb3 - these would have to be different services?
it was all so straight forward with running dockers 'run' command directly... now it seems a little more confusing for state-full containers (replica set members), as oppose to stateless containers, where all containers of a service are the same...
any pointers or links will be helpful.
I realized, via official mongodb guides for a replica set on top of Kubernetes, that you have to declare a new service per replica-set member.
So for a basic replica-set you declare 3 services, one primary, two secondaries - service__primary, service__secondary_1, service_secondary_2.
Each of these swarm services is then only proxying/load-balancing to a single container, that is running the mongod process.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With