From d3a9177cc389c11fd8325310764480a19cb18591 Mon Sep 17 00:00:00 2001 From: Saheem Hussain <76215329+saheem128@users.noreply.github.com> Date: Mon, 11 Dec 2023 19:23:04 +0530 Subject: [PATCH] state replset member for re-election on restart --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 197bbb8..a210b87 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM mongo:5 # we take over the default & start mongo in replica set mode in a background task ENTRYPOINT mongod --port $MONGO_REPLICA_PORT --replSet rs0 --bind_ip_all & MONGOD_PID=$!; \ # we prepare the replica set with a single node and prepare the root user config -INIT_REPL_CMD="rs.initiate()"; \ +INIT_REPL_CMD="rs.initiate({'_id':'rs0', 'members':[{'_id':0, 'host':'localhost:$MONGO_REPLICA_PORT'}]})"; \ # we wait for the replica set to be ready and then submit the commands just above until (mongo admin --port $MONGO_REPLICA_PORT --eval "$INIT_REPL_CMD"); do sleep 1; done; \ # we are done but we keep the container by waiting on signals from the mongo task