I'm trying to configure a replica set for Mongo in a Docker container. I've added replica set to the mongod.conf file:
replication:
replSetName: "rs0"
But during startup, I encounter the following exception:
BadValue: security.keyFile is required when authorization is enabled with replica sets
Since it's just a development environment, I don't want to create any secret keys for now. Therefore, I've disabled authorization:
security:
authorization: disabled
replication:
replSetName: "rs0"
However, this does not resolve the issue, and the exception persists. How can I configure MongoDB in a Docker container with a replica set and without authorization?
Specifying the root user and password when running in docker (i.e. docker run [...snip...] -e MONGO_INITDB_ROOT_USERNAME=myuser -e MONGO_INITDB_ROOT_PASSWORD=mypassword) also leads to MongoDB requiring a keyfile.
If you disable authorization and don't specify a keyfile, MongoDB doesn't require a keyfile (as of mongo:6)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With