-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check if database is present on every run, not just on init #173
Comments
That might be possible for the |
@yosifkit I agree :) A also thought of that issue. As I can see there are 3 common strategies for such cases:
Probably the cleanest and the most explicit is the "Fail fast" option. With some examples in docs how to repair manually, e. g. run The downside of "Try to repair" option is the risk of "zombie" databases which is never actually used. But it's also more convenient as it provides max automation. The first option seems a little bit confusing to me: a "broken" container may run without reporting any errors. Maybe some warnings would be helpful. |
I have a similar use case I would like to be able to leverage on this image/container. I am writing it here but I can definitely open a separate issue if better. Just like @rudyryk requirement the core question is if at re-init (so if a container is created again) the creation of the db or any other init operation (just like the running of the scripts in /docker-entrypoint-initdb.d) should be done again or at least checked. I am using a init.sh inside /docker-entrypoint-initdb.d and it is not rerun when I down and up my container (reference to docker-compose). I have the data mounted from a volume and so the db is always there but also perform some checks on the init script that might rerun some small changes on the new container. Would it be reasonable to have an extra piece of functionality that allowed to force the init on every container creation? ie |
Whew, coming back to this one after eons 😅 Unfortunately, this is not behavior that we're going to implement in the image as-is. However, the customization provided by #496 makes it somewhat more straightforward than it was before to replicate/create this behavior yourself -- high-level, you'd source |
As far as I can see from the
docker-entrypoint.sh
it checks for the presence of database only on the first container start.I suggest performing this check on every start.
I see some possible scenarios:
So In both cases, we just should check if the database already exists and if not then create a new one.
I'm not good at shell programming, not sure if I can make a PR :)
The text was updated successfully, but these errors were encountered: