docker-library / docker-library/mongo

Cannot create sharded cluster from version 5.0

Open
#644 3 comments 0 reactions 0 assignees View on GitHub

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:

  1. _mongod_hack_ensure_no_arg --configsvr "${mongodHackedArgs[@]}" (line 318)
  2. _mongod_hack_ensure_no_arg --shardsvr "${mongodHackedArgs[@]}" (line 319)
  3. __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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.