Single Node MongoDB Replica Set with Docker Compose
Toph needs a few MongoDB features that only work in replica set mode. Take Change Streams, for example. It is unavailable in standalone mode.
To ease development, all of Toph’s application codebases come with Docker Compose files. With just a single
docker-compose up, I can have any of Toph’s applications running in a development environment. But having MongoDB start in replica set mode has been a bit of work.
You see, simply starting three nodes and then going in to configure them to be in a replica set wasn’t something I wanted to do. I wanted only a single node to run, and I wanted it to start in replica mode, even if I was running
docker-compose up on a freshly installed machine.
So here is what I had to do:
1. Add MongoDB to
4. Generate a
keyfile for MongoDB Replica Set:
And, We Are Done!
You can now start the containers with Docker Compose:
This post is 4th of my #100DaysToOffload challenge. Want to get involved? Find out more at 100daystooffload.com.
comments powered by Disqus