As we covered in Chapter 13, Deploying a Replica Set, Docker technology can be used to model a sharded cluster as well. In this case, however, in order to minimize the impact it has on a single development computer, all replica sets are modeled as single-node replica sets. This greatly reduces system requirements and allows DevOps to model the replica set on computers that are potentially less powerful than the ones used in actual production.
A single node replica set is simply a single mongod instance assigned a unique replica set name. When initiating the replica set, the replica set configuration document, which is supplied as an argument to rs.initiate(), only contains a single member name. When the mongod instance is started, seeing as there is only one member, it automatically elects itself as the primary.
In this sub-section, we'll examine the Docker Compose configuration, individual Dockerfiles, a common hosts file, and the mongod...