Skip to content

/docker-entrypoint-initdb.d/ equivalent for scripts at every start? #642

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

Closed
shoooe opened this issue Feb 26, 2020 · 5 comments
Closed

/docker-entrypoint-initdb.d/ equivalent for scripts at every start? #642

shoooe opened this issue Feb 26, 2020 · 5 comments
Labels
question Usability question, not directly related to an error with the image

Comments

@shoooe
Copy link

shoooe commented Feb 26, 2020

Feature

Would it be possible to have a /docker-entrypoint-initdb.d/ equivalent for scripts that should be run before the database is externally accessible at every container startup?

Use case

My specific use case is to run migration scripts at container startup.

Implementation idea

The way I'm imagining it is extending docker-entrypoint.sh so that:

  • it checks if a folder like /docker-entrypoint-startdb.d/ (notice startdb instead of initdb) exists
  • starts the temp server if the database doesn't exist or if the database exists but the folder /docker-entrypoint-startdb.d/ exists
  • runs every script inside the /docker-entrypoint-startdb.d/ directory after the /docker-entrypoint-initdb.d/ scripts

Rationale

It's very difficult to extend this image with this functionality without writing a custom docker-entrypoint.sh file (which would then not be updated when this image gets updated).

@wglambert wglambert added the question Usability question, not directly related to an error with the image label Feb 26, 2020
@wglambert
Copy link

Something like this MariaDB/mariadb-docker#284 (comment)?

run startup scripts on container restarts on existing (ie. not new) volumes.

@shoe-diamente
Copy link

Do you mean this: MariaDB/mariadb-docker#284 (comment)?

It's a possible solution but writing your own docker-entrypoint.sh is suboptimal. If this image's docker-entrypoint.sh changes (which seems to have happened between that comment and the current state of docker-entrypoint.sh) to introduce bug fixes or security fixes I won't get the benefits of those changes because I have my custom docker-entrypoint.sh.

Moreover is the API compatibility of bash functions in docker-entrypoint.sh guaranteed ? Will upgrading the image to a new minor version guarantee that those bash functions will still be there?

@yosifkit
Copy link
Member

Moreover is the API compatibility of bash functions in docker-entrypoint.sh guaranteed ? Will upgrading the image to a new minor version guarantee that those bash functions will still be there?

The functions not beginning with an underscore are considered the "public" interface of the script when sourcing it and so will be kept as a stable as possible (functionality, names, and arguments will be very unlikely to change). On the flip side, functions beginning with an underscore are "private" and can change at any time.

I am trying to work on documenting their intended functionality and any arguments, but haven't been able to get to it yet. The spreadsheet linked from #471 contains their current description and any discussion of their creation (and any that accept arguments should be commented in the function itself).

@wglambert
Copy link

Going to close as this seems sufficiently answered

@shoe-diamente
Copy link

Yeah I managed it, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Usability question, not directly related to an error with the image
Projects
None yet
Development

No branches or pull requests

4 participants