I tried to make a docker container that runs a Mongo DB 6.0.5 as a single-node replication set.
But every time when I tried, the container stopped, and I got an error: MongoServerError: This node was not started with replication enabled.
DockerFile:
FROM mongo:latest
ENV TZ="Europe/Budapest"
ENV TIME_ZONE="Europe/Budapest"
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
RUN echo "rs.initiate({'_id':'rs0', members: [{'_id':1, 'host':'127.0.0.1:27017'}]});" > "/docker-entrypoint-initdb.d/init_replicaset.js"
RUN echo "********************" > "/tmp/key.file"
COPY ./mongo_init.js /docker-entrypoint-initdb.d/init_users.js
RUN chmod 600 /tmp/key.file
RUN chown 999:999 /tmp/key.file
Hi @Hegyi_Gergely and welcome to the MongoDB community forum!!
Firstly, the image mentioned above does not seem valid MongoDB image. Can you confirm if this is a custom image created for the application.
However, please note that, there are two images:
Sorry, but there are more problems with this example:
mongoinit: /usr/local/bin/docker-entrypoint.sh: line 420: exec: mongo: not found
The mongo replaced to mongosh in V6. Are you sure to use MongoDB V6?
you should update the lates mongo image:
docker pull mongo
mongo1…3:
“id”:4939300, “ctx”:“monitoring-keys-for-HMAC”,“msg”:“Failed to refresh key cache”,“attr”:{“error”:“NotYetInitialized: Cannot use non-local read concern until replica set is finished initializing.”,“nextWakeupMillis”:3600}}