Hi,
I have two usage scenarios where imho it would make a lot of sense to have the option to just init a postgres DBMS via scripts in /docker-entrypoint-initdb.d and then have the docker container exit gracefully as soon as those init scripts are run.
This would support my following use cases:
wdyt?
+1 - this would be super useful for seeding data into a container and then recommitting it (think allowing developers to pull a container with seeded data already inside it
The last line of the docker-entrypoint.sh seems to be responsible for starting the database.That is
exec "$@"
As a hacky way to accomplish not starting the database, i currently remove the last line of docker-entrypoint.sh using a RUN command with sed inside the Dockerfile like this:
RUN sed -i '$ d' /usr/local/bin/docker-entrypoint.sh
As a more permanent solution, an ENV variable (e.g $DONT_START_DATABASE) and a change to the last lines of the docker-entrypoint.sh to exit the script succesfully before starting the database would be great. Example:
if [ "$DONT_START_DATABASE" = true ]; then
exit 0;
fi
exec "$@"
As a plus, other people using the hacky solution with sed wouldn't be affected by the change.
What do you think?
I have a similar kubernetes situation with the following in an init container:
- name: setup
image: postgres
args:
# Trick entrypoint into exiting after setup
- postgres
- --version
I think the --version or sed-based solution (https://github.com/docker-library/postgres/issues/424#issuecomment-445552662) is the best we can offer right now, but https://github.com/docker-library/postgres/pull/496 should make this process completely customizable (which should make this a lot easier to accomplish).
This is now possible to accomplish properly/cleanly via #496. :tada: :+1:
I have a similar kubernetes situation with the following in an init container:
- name: setup image: postgres args: # Trick entrypoint into exiting after setup - postgres - --version
Looks like trick does not work anymore
Most helpful comment
The last line of the
docker-entrypoint.shseems to be responsible for starting the database.That isAs a hacky way to accomplish not starting the database, i currently remove the last line of
docker-entrypoint.shusing aRUNcommand with sed inside the Dockerfile like this:As a more permanent solution, an ENV variable (e.g $DONT_START_DATABASE) and a change to the last lines of the
docker-entrypoint.shto exit the script succesfully before starting the database would be great. Example:As a plus, other people using the hacky solution with sed wouldn't be affected by the change.
What do you think?