docker-library / docker-library/mongo
Cannot create sharded cluster from version 5.0
Nobody has claimed this yet.
- Dominant language
- Shell
- Stars
- 1.1k
- Forks
- 658
- Avg merge
- 4h 40m
- Merged PRs (30d)
- 1
Description
Hello,
I'm having issues on upgrading local sharded cluster from version 4.4 to 5.
For example, Dockerfile for config and shard servers looks like this:
FROM mongo:5.0.21
COPY key /key
COPY scripts /scripts
RUN chown -R mongodb /key
RUN chown -R mongodb /scripts
Docker-compose.yml:
...
mongo_config:
build: ../mongo-cluster/image
container_name: mongo_config
command: mongod --port 27017 --configsvr --replSet configserver --keyFile /key/mongodb.key
env_file:
- ../mongo-cluster/mongo-credentials.env
...
Issue is in docker-entrypoint.sh where the script removes --replSet switch when trying to start un-authenticated mongod version to add root user and password provided in the environment file. The error presented is:
BadValue: Cannot start a configsvr as a standalone server. Please use the option --replset to start the node as a replica set.
It should remove both --configsvr and --shardsvr switches, plus add --dbPath switch because config server uses a different path.
When I try adding this options everything works.
Additions are:
- _mongod_hack_ensure_no_arg --configsvr "${mongodHackedArgs[@]}" (line 318)
- _mongod_hack_ensure_no_arg --shardsvr "${mongodHackedArgs[@]}" (line 319)
- __mongod_hack_ensure_arg_val --dbpath "$(dbPath "$@")" "${mongodHackedArgs[@]}" (line 344)
Is this something that can be added/modified officially?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read docker-entrypoint.sh around lines 317–344, then compare the reported Dockerfile and docker-compose.yml setup for config and shard servers. Verify that MongoDB 5.0 authentication initialization preserves the required replica-set and server-role options and uses the config server's dbPath; done means the sharded cluster starts successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, mongodb, shell
- Domain
- databases, devops
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100