Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB. BadValue: security.keyFile is required when authorization is enabled with replica sets

Tags:

docker

mongodb

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?

like image 384
Volodya Lombrozo Avatar asked Dec 17 '25 17:12

Volodya Lombrozo


1 Answers

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)

like image 162
user3391859 Avatar answered Dec 20 '25 11:12

user3391859



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!