Initialization of a user defined database, username, and password using environment variables
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 32/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- docker, mongodb, shell
- Domain
- databases, devops, documentation
Research direction
Start by reading docker-entrypoint.sh and the documentation describing MONGO_INITDB_DATABASE, then review the referenced issue and pull request for existing behavior. Done means the proposed environment variables have the stated root and user-database semantics, initialization scripts run against the specified user database, and the documentation explains each variable clearly.
Written by the indexing model from the issue text.
Description
This issue (I would call it a bug but perhaps it is a feature request) is that users would like to a la docker-compose.yml and/or environment variables be able to set a database with a username and password they specify upon launch of the image.
Background:
This issue was filed https://github.com/docker-library/mongo/issues/174 and closed because the behavior of a PR https://github.com/docker-library/mongo/pull/145 was mentioned as the solution. What https://github.com/docker-library/mongo/pull/145 actually does and what users expect are entirely different. What PR https://github.com/docker-library/mongo/pull/145 does is set a user with elevated permissions (i.e. "root" user) that has superuser access to the entire MongoDB instance (as mentioned in https://github.com/docker-library/mongo/issues/174#issuecomment-460448991. However what most users expect from these environment variables is that a database they specify is initialized with the username and password they have set. It is confusing that these environment variables (MONGO_INITDB_DATABASE, MONGO_INITDB_ROOT_PASSWORD and MONGO_INITDB_ROOT_USERNAME) pertain to only setting a user with the role root on the database admin and initializing an user specified database for .js and .sh scripts in /docker-entrypoint-initdb.d/ to be run against.
Proposal:
We should make the environment variables very explicitly named in what they do in addition to adding others for the behavior I think most users come to expect when reading the variable names. Since it is the case most users would like their instance initialized with a database of their specification we should add this feature to meet that expectation.
- We keep
MONGO_INITDB_ROOT_USERNAMEandMONGO_INITDB_ROOT_PASSWORD - We remove
MONGO_INITDB_DATABASEas it is misleading - We add
MONGO_INITDB_ROOT_DATABASEand allow it to override the hardcodedadmindatabase - We add
MONGO_USERDB_ADMIN_USERNAME,MONGO_USERDB_ADMIN_PASSWORD, andMONGO_USERDB_ADMIN_DATABASE - We update the documentation to state:
MONGO_INITDB_ROOT_USERNAME,MONGO_INITDB_ROOT_PASSWORD, andMONGO_INITDB_ROOT_DATABASEwill be used for therootrole to Mongo
MONGO_USERDB_ADMIN_USERNAME,MONGO_USERDB_ADMIN_PASSWORD, andMONGO_USERDB_ADMIN_DATABASEwill be used to initialize a user specified database- That all of the
.jsand.shscripts a user supplies in/docker-entrypoint-initdb.d/will be executed againstMONGO_USERDB_ADMIN_DATABASE
Reasons for change:
- The variables
MONGO_INITDB_ROOT_PASSWORDandMONGO_INITDB_ROOT_USERNAMEare only used for theadmindatabase - Currently all
MONGO_INITDB_DATABASEdoes is have operations used against it whenever a user has dropped in.jsor.shscripts into/docker-entrypoint-initdb.d/. This unclear unless you look atdocker-entrypoint.shin this repository and no where clearly stated in the documentation as such - The documentation is unclear and the only way to hack in a user initialized database with a username and password on image launch is to also create a script in
/docker-entrypoint-initdb.d/which then places burden on the user to maintain therootrole credentials in environment variables which live separately from a custom.jsor.shscript which they have to volume into the image
References:
- Issue: https://github.com/docker-library/mongo/issues/174
- PR: https://github.com/docker-library/mongo/pull/145
Involved Persons:
@mmi-rperez
@tianon
@vutran1710
@yosifkit
@lonix1
@johnwyles
- Dominant language
- Shell
- Stars
- 1.1k
- Forks
- 658
- Avg merge
- 4h 40m
- Merged PRs (30d)
- 1
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.
More from docker-library/mongo
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
docker-library/mongo#769 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
docker-library/mongo#762 · 9 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
docker-library/mongo#761 · 2 comments · 4 reactions ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
docker-library/mongo#760 · 4 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
docker-library/mongo#730 · 2 comments ·
All issues in docker-library/mongo
Similar issues
-
docs(agents): strengthen the no-backslash-escaped-backticks rule with an issue-creation example Open
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
package-update
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
oSoWoSo/vOid_Community_repOsitory#148 · 1 comment ·
-
chore
Difficulty 1/5 Under an hour Newbie friendliness 91/100
alunduil/alunduil-chezmoi#792 ·
-
area: compat bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
zenhub-dev
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
OpenLiberty/ci.docker#747 ·