You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm evaluating the DHI MongoDB image as a base image for my project and would like to know whether there are plans to provide built-in replica set initialization support via the entrypoint script.
Problem
Setting up a MongoDB replica set inside a container requires a complex, multi-step initialization sequence involving at least two restart cycles of the mongod daemon:
First startup: Start mongod without authentication, create an admin user, then stop the daemon.
Second startup: Start mongod with authentication enabled, authenticate as the admin user, run rs.initiate() to configure the replica set, then stop the daemon again.
Final startup: Start mongod with the user's desired runtime options (authentication, replica set name, keyFile, custom config, etc.).
Implementing this orchestration in a custom entrypoint script is highly error-prone and burdensome for image consumers. It requires careful handling of daemon lifecycle, readiness checks, authentication state transitions, and signal forwarding — concerns that ideally belong in the image itself, not in every downstream project.
Context
The official MongoDB community image (docker-library/mongo) does not provide replica set initialization support, likely for historical reasons. There are numerous issues and workarounds in the repository from users trying to achieve this. I currently maintain a custom entrypoint script on top of the official image to handle this workflow, but I do not consider it a good long-term solution — it is fragile, hard to maintain, and tightly coupled to the upstream entrypoint's internal implementation details.
For reference, bitnami/mongodb is an example of a container image that does provide built-in replica set configuration support, demonstrating that this is a well-understood and solvable problem at the image level.
Request
It would be extremely valuable if the DHI MongoDB image provided first-class support for replica set initialization, for example, via environment variables or configuration options that handle the full lifecycle described above. This would:
Eliminate a major pain point for anyone running MongoDB in containers with replica sets (which is increasingly the default, as many MongoDB features require replica sets — e.g., change streams, transactions).
Differentiate DHI from the official community image in a meaningful way beyond security hardening.
Reduce the need for fragile custom entrypoint hacks in downstream projects.
Questions
Does the DHI MongoDB image currently support any form of replica set initialization that I may have missed?
If not, is this something the DHI team is considering for future releases?
Would the DHI team be open to contributions or feature requests toward this goal?
Thank you for making DHI freely available — it's a great initiative. I'd love to adopt it fully for MongoDB, and built-in replica set support would make that transition much smoother.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
I'm evaluating the DHI MongoDB image as a base image for my project and would like to know whether there are plans to provide built-in replica set initialization support via the entrypoint script.
Problem
Setting up a MongoDB replica set inside a container requires a complex, multi-step initialization sequence involving at least two restart cycles of the
mongoddaemon:mongodwithout authentication, create an admin user, then stop the daemon.mongodwith authentication enabled, authenticate as the admin user, runrs.initiate()to configure the replica set, then stop the daemon again.mongodwith the user's desired runtime options (authentication, replica set name, keyFile, custom config, etc.).Implementing this orchestration in a custom entrypoint script is highly error-prone and burdensome for image consumers. It requires careful handling of daemon lifecycle, readiness checks, authentication state transitions, and signal forwarding — concerns that ideally belong in the image itself, not in every downstream project.
Context
The official MongoDB community image (docker-library/mongo) does not provide replica set initialization support, likely for historical reasons. There are numerous issues and workarounds in the repository from users trying to achieve this. I currently maintain a custom entrypoint script on top of the official image to handle this workflow, but I do not consider it a good long-term solution — it is fragile, hard to maintain, and tightly coupled to the upstream entrypoint's internal implementation details.
For reference, bitnami/mongodb is an example of a container image that does provide built-in replica set configuration support, demonstrating that this is a well-understood and solvable problem at the image level.
Request
It would be extremely valuable if the DHI MongoDB image provided first-class support for replica set initialization, for example, via environment variables or configuration options that handle the full lifecycle described above. This would:
Questions
Thank you for making DHI freely available — it's a great initiative. I'd love to adopt it fully for MongoDB, and built-in replica set support would make that transition much smoother.
Beta Was this translation helpful? Give feedback.
All reactions