Closed harrybvp closed 6 years ago
It is not something we had considered. Is it something that could be accomplished with HEALTHCHECK
in your Dockerfile or in your docker run
?
@yosifkit Thanks for response! I have a requirement to do more than a health checkup (some business logic) on each container start. I think it would be great to have that support in docker-entrypoint.sh
However for now , I created an Dockerfile with based image as postgres and added a RUN command to modify docker-entrypoint.sh using sed (inserting my logic somewhere in that entry point script).
I have another scenario which requires running a command each time the container is started. My build system outputs a generated script that adds database roles (if not exists) for currently enabled services. The new roles.sql
file in the docker-entrypoint-initdb.d/
triggers a rebuild of the image. That triggers docker-compose to recreate the postgres container. The data directory comes from a persistent volume, however, and due its presence the new init scripts are not run even though they are written to handle existing data.
It would be useful to have the entrypoint trigger scripts for different events. e.g., docker-entrypoint-initdb.d/
for a brand spanking new containers like today, and scripts in docker-entrypoint-on-every-start.d/
every time a container is started.
It's a mongo
example, but it should be applicable to postgres
as well: https://github.com/docker-library/mongo/issues/249#issuecomment-381786889 (basically, start a process in the background that waits for the database to be up and ready before starting the database itself, then make sure it exits cleanly after the desired business logic is performed).
Closing, since we have no intention of explicitly supporting this in the image itself.
It's a
mongo
example, but it should be applicable topostgres
as well: docker-library/mongo#249 (comment) (basically, start a process in the background that waits for the database to be up and ready before starting the database itself, then make sure it exits cleanly after the desired business logic is performed).Closing, since we have no intention of explicitly supporting this in the image itself.
This is not applicable to postgres cause docker-entrypoint.sh
runs only if it's not sourced or executed from another file:
https://github.com/docker-library/postgres/blob/master/14/alpine3.18/docker-entrypoint.sh#L349-L351
This is not applicable to postgres cause
docker-entrypoint.sh
runs only if it's not sourced or executed from another file: https://github.com/docker-library/postgres/blob/master/14/alpine3.18/docker-entrypoint.sh#L349-L351
And this scenario is covered by the example I gave when creating the source-able entrypoint: https://github.com/docker-library/postgres/pull/496#issue-358838955
It would be great to use to auto-tune PostgreSQL RAM needs. Define max RAM in docker-compose file, restart the container, watch it auto configure.
I realize this was 8 years, but anybody interested can see this little beauty of mine: how to run autotune script and restart server after the database (and the initial configuration) has been created -- use "docker-ensure-initdb.sh" of course, here's an example: https://github.com/iplweb/bpp/tree/dev/deploy/dbserver
Currently scripts present inside docker-entrypoint-initdb.d/* will run only once (during initialization).
I have a script which does health checkup and I would like that script to be executed always i.e. whenever container starts.
One way could be to modify docker-entrypoint.sh but i was wondering if it's possible w/o modifying entrypoint script.