Current State
- I have a MongoDB instance running on a server without the replication set flag (
--replSet) - I have some previously stored information on the Database and wish to retain the information
Aim
- I wish to however restart the container with the
--replSet "my-set"flag set for the daemon and keep the previous information intact
Implementation
I am trying to follow along a tutorial for setting replica sets in MongoDB with Docker and trying it out on my local machine.
Create a standard MongoDB Docker container w/o the flag
replSetset which represents the current state:docker run -d --name mongo_rs --publish 37017:27017 mongoUsing the MongoDB Compass I connected to the DB and added some dummy information to a Database called
testand collection calledplayersI stop the container:
docker container stop mongo_rs
From here onwards I wish to add the --replSet "my-set" to the mongo_rs container and configuring the Replica set via the mongo Shell as mentioned in the tutorial. What is the possible solution for achieving it?