mongo
mongo copied to clipboard
mongo:5.0.3 - Failed to run container with initdb
Step to reproduce
docker run --rm -e MONGO_INITDB_ROOT_USERNAME=root -e MONGO_INITDB_ROOT_PASSWORD=root mongo:5.0.3 mongod --shardsvr --replSet a
or
docker run --rm -e MONGO_INITDB_ROOT_USERNAME=root -e MONGO_INITDB_ROOT_PASSWORD=root mongo:5.0.3 mongod --configsvr --replSet a
Actual result
BadValue: Cannot start a shardsvr as a standalone server. Please use the option --replset to start the node as a replica set.
try 'mongod --help' for more information
Starts from 5.0.3 mongod requires replica set for shardsvr
or configsvr
cluster role (issue - https://jira.mongodb.org/browse/SERVER-27383)
It is caused by this code: https://github.com/docker-library/mongo/blob/master/5.0/docker-entrypoint.sh#L286
- it doesn't make sense to try to add an admin user/pass to a shard server, since they don't store the
admin
database (that's on the config server). It also doesn't make sense to try to run any scripts in/docker-entrypoint-initdb.d/
, since, as far as I understand it, you need to go through amongos
server in order to talk to a sharded cluster.- so, we should probably adjust the entrypoint script to either warn & ignore if any of that is attempted on a
shardsvr
or just error out if they are supplied withshardsvr
- so, we should probably adjust the entrypoint script to either warn & ignore if any of that is attempted on a
- as for user/pass with
configsvr
, that still works for 4.4, but replica set being required in 5.0 complicates things.- since
replSet
does not work correctly on the temporarymongod
server, we should also removeconfigsvr
but preserve its defaultdbPath
for the temporarymongod
server so that data is in the correct location
- since
Finally have a PR to address the configsvr
half of this issue: https://github.com/docker-library/mongo/pull/600.