Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix configsvr with user/pass env vars on 5.0 & 6.0 #600

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yosifkit
Copy link
Member

@yosifkit yosifkit commented Jan 4, 2023

Since 5.0, setting the sharding.clusterRole/--configsvr requires it to be part of a replica set so this fixes part of #509 (for --configsvr). Not certain we need to do anything for --shardsvr since they shouldn't use the entrypoint user/pass or initdb.d scripts there.

BadValue: Cannot start a configsvr as a standalone server. Please use the option --replSet to start the node as a replica set.
try 'mongod --help' for more information

Technically, adding --auth (via adding user/pass) also requires a keyFile for a replset, but that is something the user needs to add (not something we can fix in the entrypoint)

$ docker run -it --rm \
-v "$PWD/data:/data/configdb" \
-v "$PWD/keyfile:/keyfile:ro" \
--user [data & keyfile directory owner] \
--env MONGO_INITDB_ROOT_USERNAME=admin \
--env MONGO_INITDB_ROOT_PASSWORD=password \
--name mongo-cfg \
mongo:6.0 --configsvr --replSet rep --keyFile /keyfile/test.key

(I'd recommend users also set --hostname when using replica sets depending on how they set up members in their replica configuration rs.init(...).)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants