Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (47.6k points)

What is the best practice when creating a MongoDB replica set using Docker?

1 Answer

0 votes
by (106k points)

There are many ways to create a MongoDB replica set using Docker. Some of them are as follows:-

  1. You can use the host’s local directory. For that, you will need to create one service for every replica, and use the constraint to schedule the container to one specific host. You will also need to configure each replica and set up the replication by yourself. While, when one node goes down, one replica will go down. You will need to work to bring up another replica.

  2. Another thing that you can do is use the volume plugin, such as flicker, REX-Ray. You will still need to create one service for every replica, and bind one volume to one service. You need to create all services in the same overlay network, configure each replica and set up the replication. The application needs to use the same overlay network to access MongoDB, or else the proxy needs to be set up.

  3. Last but not least you can use FireCamp. FireCamp is an open-source project to simplify the setup and management of stateful services, including MongoDB, on docker. It does all the manual works for you. So you could set up a MongoDB replica set via one command.

If you want to learn Docker then I would suggest you must take up the following Docker training Course. I am also mentioning a video tutorial for your reference which you must watch to learn more about it.

.

Browse Categories

...