Skip to content

Fix configsvr with user/pass env vars #600

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

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(...).)

@theDanielJLewis
Copy link

Will this or a similar fix ever be merged?

@tianon
Copy link
Member

tianon commented Dec 4, 2024

As noted by @yosifkit in #717 (comment), we're still not sure this is actually a "correct" fix (and frankly the entrypoint scripts here are already doing way more than we're comfortable with maintaining, which is part of why we avoided adding even the basic functionality they currently have for so long).

@theDanielJLewis
Copy link

So … should I assume this will not be fixed for a while?

@yosifkit yosifkit changed the title Fix configsvr with user/pass env vars on 5.0 & 6.0 Fix configsvr with user/pass env vars Mar 18, 2025
@yosifkit
Copy link
Member Author

So … should I assume this will not be fixed for a while?

I rebased the PR to keep it up to date, but we are still unsure that it is correct.

@theDanielJLewis
Copy link

Thanks!

There's probably no way for me to test the docker image without building it myself, is there? In my hosting environment, I can only add a docker image, like mongo:8.

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.

3 participants