diff --git a/4.2/docker-entrypoint.sh b/4.2/docker-entrypoint.sh index 0073c4f0d0..e1dd822f00 100755 --- a/4.2/docker-entrypoint.sh +++ b/4.2/docker-entrypoint.sh @@ -206,12 +206,21 @@ _parse_config() { cat >&2 "$jsonConfigFile" exit 1 fi - jq 'del(.systemLog, .processManagement, .net, .security, .replication)' "$jsonConfigFile" > "$tempConfigFile" + jq 'del(.systemLog, .processManagement, .net, .security, .replication, .sharding)' "$jsonConfigFile" > "$tempConfigFile" return 0 fi return 1 } + +_isConfigServer() { + _mongod_hack_have_arg --configsvr "$@" || { + _parse_config "$@" \ + && clusterRole="$(jq -r '.sharding.clusterRole // empty' "$jsonConfigFile")" \ + && [ "$clusterRole" = 'configsvr' ] + } +} + dbPath= _dbPath() { if [ -n "$dbPath" ]; then @@ -226,11 +235,7 @@ _dbPath() { fi if [ -z "$dbPath" ]; then - if _mongod_hack_have_arg --configsvr "$@" || { - _parse_config "$@" \ - && clusterRole="$(jq -r '.sharding.clusterRole // empty' "$jsonConfigFile")" \ - && [ "$clusterRole" = 'configsvr' ] - }; then + if _isConfigServer "$@"; then # if running as config server, then the default dbpath is /data/configdb # https://docs.mongodb.com/manual/reference/program/mongod/#cmdoption-mongod-configsvr dbPath=/data/configdb @@ -314,6 +319,12 @@ if [ "$originalArgOne" = 'mongod' ]; then if [ "$MONGO_INITDB_ROOT_USERNAME" ] && [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then _mongod_hack_ensure_no_arg_val --replSet "${mongodHackedArgs[@]}" fi + # Setting sharding.clusterRole=configsvr requires the mongod instance to be running with replication + # disable configsvr for initial startup (https://github.com/docker-library/mongo/issues/509) + if _isConfigServer "$@"; then + _mongod_hack_ensure_no_arg '--configsvr' "${mongodHackedArgs[@]}" + _mongod_hack_ensure_arg_val '--dbpath' "$dbPath" "${mongodHackedArgs[@]}" + fi # "BadValue: need sslPEMKeyFile when SSL is enabled" vs "BadValue: need to enable SSL via the sslMode flag when using SSL configuration parameters" tlsMode='disabled' diff --git a/4.4/docker-entrypoint.sh b/4.4/docker-entrypoint.sh index 0073c4f0d0..e1dd822f00 100755 --- a/4.4/docker-entrypoint.sh +++ b/4.4/docker-entrypoint.sh @@ -206,12 +206,21 @@ _parse_config() { cat >&2 "$jsonConfigFile" exit 1 fi - jq 'del(.systemLog, .processManagement, .net, .security, .replication)' "$jsonConfigFile" > "$tempConfigFile" + jq 'del(.systemLog, .processManagement, .net, .security, .replication, .sharding)' "$jsonConfigFile" > "$tempConfigFile" return 0 fi return 1 } + +_isConfigServer() { + _mongod_hack_have_arg --configsvr "$@" || { + _parse_config "$@" \ + && clusterRole="$(jq -r '.sharding.clusterRole // empty' "$jsonConfigFile")" \ + && [ "$clusterRole" = 'configsvr' ] + } +} + dbPath= _dbPath() { if [ -n "$dbPath" ]; then @@ -226,11 +235,7 @@ _dbPath() { fi if [ -z "$dbPath" ]; then - if _mongod_hack_have_arg --configsvr "$@" || { - _parse_config "$@" \ - && clusterRole="$(jq -r '.sharding.clusterRole // empty' "$jsonConfigFile")" \ - && [ "$clusterRole" = 'configsvr' ] - }; then + if _isConfigServer "$@"; then # if running as config server, then the default dbpath is /data/configdb # https://docs.mongodb.com/manual/reference/program/mongod/#cmdoption-mongod-configsvr dbPath=/data/configdb @@ -314,6 +319,12 @@ if [ "$originalArgOne" = 'mongod' ]; then if [ "$MONGO_INITDB_ROOT_USERNAME" ] && [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then _mongod_hack_ensure_no_arg_val --replSet "${mongodHackedArgs[@]}" fi + # Setting sharding.clusterRole=configsvr requires the mongod instance to be running with replication + # disable configsvr for initial startup (https://github.com/docker-library/mongo/issues/509) + if _isConfigServer "$@"; then + _mongod_hack_ensure_no_arg '--configsvr' "${mongodHackedArgs[@]}" + _mongod_hack_ensure_arg_val '--dbpath' "$dbPath" "${mongodHackedArgs[@]}" + fi # "BadValue: need sslPEMKeyFile when SSL is enabled" vs "BadValue: need to enable SSL via the sslMode flag when using SSL configuration parameters" tlsMode='disabled' diff --git a/5.0/docker-entrypoint.sh b/5.0/docker-entrypoint.sh index 0073c4f0d0..e1dd822f00 100755 --- a/5.0/docker-entrypoint.sh +++ b/5.0/docker-entrypoint.sh @@ -206,12 +206,21 @@ _parse_config() { cat >&2 "$jsonConfigFile" exit 1 fi - jq 'del(.systemLog, .processManagement, .net, .security, .replication)' "$jsonConfigFile" > "$tempConfigFile" + jq 'del(.systemLog, .processManagement, .net, .security, .replication, .sharding)' "$jsonConfigFile" > "$tempConfigFile" return 0 fi return 1 } + +_isConfigServer() { + _mongod_hack_have_arg --configsvr "$@" || { + _parse_config "$@" \ + && clusterRole="$(jq -r '.sharding.clusterRole // empty' "$jsonConfigFile")" \ + && [ "$clusterRole" = 'configsvr' ] + } +} + dbPath= _dbPath() { if [ -n "$dbPath" ]; then @@ -226,11 +235,7 @@ _dbPath() { fi if [ -z "$dbPath" ]; then - if _mongod_hack_have_arg --configsvr "$@" || { - _parse_config "$@" \ - && clusterRole="$(jq -r '.sharding.clusterRole // empty' "$jsonConfigFile")" \ - && [ "$clusterRole" = 'configsvr' ] - }; then + if _isConfigServer "$@"; then # if running as config server, then the default dbpath is /data/configdb # https://docs.mongodb.com/manual/reference/program/mongod/#cmdoption-mongod-configsvr dbPath=/data/configdb @@ -314,6 +319,12 @@ if [ "$originalArgOne" = 'mongod' ]; then if [ "$MONGO_INITDB_ROOT_USERNAME" ] && [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then _mongod_hack_ensure_no_arg_val --replSet "${mongodHackedArgs[@]}" fi + # Setting sharding.clusterRole=configsvr requires the mongod instance to be running with replication + # disable configsvr for initial startup (https://github.com/docker-library/mongo/issues/509) + if _isConfigServer "$@"; then + _mongod_hack_ensure_no_arg '--configsvr' "${mongodHackedArgs[@]}" + _mongod_hack_ensure_arg_val '--dbpath' "$dbPath" "${mongodHackedArgs[@]}" + fi # "BadValue: need sslPEMKeyFile when SSL is enabled" vs "BadValue: need to enable SSL via the sslMode flag when using SSL configuration parameters" tlsMode='disabled' diff --git a/6.0/docker-entrypoint.sh b/6.0/docker-entrypoint.sh index 0073c4f0d0..e1dd822f00 100755 --- a/6.0/docker-entrypoint.sh +++ b/6.0/docker-entrypoint.sh @@ -206,12 +206,21 @@ _parse_config() { cat >&2 "$jsonConfigFile" exit 1 fi - jq 'del(.systemLog, .processManagement, .net, .security, .replication)' "$jsonConfigFile" > "$tempConfigFile" + jq 'del(.systemLog, .processManagement, .net, .security, .replication, .sharding)' "$jsonConfigFile" > "$tempConfigFile" return 0 fi return 1 } + +_isConfigServer() { + _mongod_hack_have_arg --configsvr "$@" || { + _parse_config "$@" \ + && clusterRole="$(jq -r '.sharding.clusterRole // empty' "$jsonConfigFile")" \ + && [ "$clusterRole" = 'configsvr' ] + } +} + dbPath= _dbPath() { if [ -n "$dbPath" ]; then @@ -226,11 +235,7 @@ _dbPath() { fi if [ -z "$dbPath" ]; then - if _mongod_hack_have_arg --configsvr "$@" || { - _parse_config "$@" \ - && clusterRole="$(jq -r '.sharding.clusterRole // empty' "$jsonConfigFile")" \ - && [ "$clusterRole" = 'configsvr' ] - }; then + if _isConfigServer "$@"; then # if running as config server, then the default dbpath is /data/configdb # https://docs.mongodb.com/manual/reference/program/mongod/#cmdoption-mongod-configsvr dbPath=/data/configdb @@ -314,6 +319,12 @@ if [ "$originalArgOne" = 'mongod' ]; then if [ "$MONGO_INITDB_ROOT_USERNAME" ] && [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then _mongod_hack_ensure_no_arg_val --replSet "${mongodHackedArgs[@]}" fi + # Setting sharding.clusterRole=configsvr requires the mongod instance to be running with replication + # disable configsvr for initial startup (https://github.com/docker-library/mongo/issues/509) + if _isConfigServer "$@"; then + _mongod_hack_ensure_no_arg '--configsvr' "${mongodHackedArgs[@]}" + _mongod_hack_ensure_arg_val '--dbpath' "$dbPath" "${mongodHackedArgs[@]}" + fi # "BadValue: need sslPEMKeyFile when SSL is enabled" vs "BadValue: need to enable SSL via the sslMode flag when using SSL configuration parameters" tlsMode='disabled' diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 0073c4f0d0..e1dd822f00 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -206,12 +206,21 @@ _parse_config() { cat >&2 "$jsonConfigFile" exit 1 fi - jq 'del(.systemLog, .processManagement, .net, .security, .replication)' "$jsonConfigFile" > "$tempConfigFile" + jq 'del(.systemLog, .processManagement, .net, .security, .replication, .sharding)' "$jsonConfigFile" > "$tempConfigFile" return 0 fi return 1 } + +_isConfigServer() { + _mongod_hack_have_arg --configsvr "$@" || { + _parse_config "$@" \ + && clusterRole="$(jq -r '.sharding.clusterRole // empty' "$jsonConfigFile")" \ + && [ "$clusterRole" = 'configsvr' ] + } +} + dbPath= _dbPath() { if [ -n "$dbPath" ]; then @@ -226,11 +235,7 @@ _dbPath() { fi if [ -z "$dbPath" ]; then - if _mongod_hack_have_arg --configsvr "$@" || { - _parse_config "$@" \ - && clusterRole="$(jq -r '.sharding.clusterRole // empty' "$jsonConfigFile")" \ - && [ "$clusterRole" = 'configsvr' ] - }; then + if _isConfigServer "$@"; then # if running as config server, then the default dbpath is /data/configdb # https://docs.mongodb.com/manual/reference/program/mongod/#cmdoption-mongod-configsvr dbPath=/data/configdb @@ -314,6 +319,12 @@ if [ "$originalArgOne" = 'mongod' ]; then if [ "$MONGO_INITDB_ROOT_USERNAME" ] && [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then _mongod_hack_ensure_no_arg_val --replSet "${mongodHackedArgs[@]}" fi + # Setting sharding.clusterRole=configsvr requires the mongod instance to be running with replication + # disable configsvr for initial startup (https://github.com/docker-library/mongo/issues/509) + if _isConfigServer "$@"; then + _mongod_hack_ensure_no_arg '--configsvr' "${mongodHackedArgs[@]}" + _mongod_hack_ensure_arg_val '--dbpath' "$dbPath" "${mongodHackedArgs[@]}" + fi # "BadValue: need sslPEMKeyFile when SSL is enabled" vs "BadValue: need to enable SSL via the sslMode flag when using SSL configuration parameters" tlsMode='disabled'