Mongo: User initialisation and --auth option

Created on 22 Mar 2017  路  3Comments  路  Source: docker-library/mongo

The new user initialisation via MONGO_INITDB_ROOT_USERNAME and MONGO_INITDB_ROOT_PASSWORD adds an --auth option to $@

This causes a problem when a user supplies --auth.

Error parsing command line:  Multiple occurrences of option "----auth"
try 'mongod --help' for more information

Which is non obvious until you look at the script.

Maybe if ! echo "$@" | grep -qw -- '--auth'; then echo "Adding --auth" ?

Most helpful comment

Thanks! for arg is one of those things that's always been there but I've never seen/used in how ever many years scripting.

All 3 comments

Yeah the mongo error is a little non-obvious. (also, why did they add the extra dashes? ----auth).

It seems sane to only add it when it is not already in the arguments.

How irritating that it can't just realize that we didn't even ask for conflicting things and accept it. :cry:

152 should help!

Thanks! for arg is one of those things that's always been there but I've never seen/used in how ever many years scripting.

Was this page helpful?
0 / 5 - 0 ratings