Add support for database update scripts.#673
Closed
ogheorghies wants to merge 1 commit intodocker-library:masterfrom
Closed
Add support for database update scripts.#673ogheorghies wants to merge 1 commit intodocker-library:masterfrom
ogheorghies wants to merge 1 commit intodocker-library:masterfrom
Conversation
The files /docker-entrypoint-updatedb.d/* are run every time a container starts, even if the database directory is not empty. This is unlike the files /docker-entrypoint-initdb.d/*, which are only run iif the database directory is empty. When the database directory is empty, the update scripts are run after the init scripts.
Suppose that the following files are present in a container image:
/docker-entrypoint-initdb.d/init.sh
/docker-entrypoint-updatedb.d/update.sh
When a new container is run for the first time with a persistent volume, for example as follows:
$ docker run --rm -it \
-v ./my-initdb.d:/docker-entrypoint-initdb.d \
-v ./my-updatedb.d:/docker-entrypoint-updatedb.d \
-v my-vol:/var/lib/postgresql/data postgres
the following init files are run, in this order:
/docker-entrypoint-initdb.d/init.sh
/docker-entrypoint-updatedb.d/update.sh
If the container is stopped and a new container is started with the same command, only this file is run:
/docker-entrypoint-updatedb.d/update.sh
Member
|
We've had similar request across MariaDB, MySQL, and PostgreSQL images (like MariaDB/mariadb-docker#284 and #179). Unfortunately we do not want to add any more complexity or configuration knobs to the image. Instead of adding every possible knob and feature, we settled on #496. Running "initdb" scripts on every run is the type of customization we built 496 for and is basically the example in my comment. Closing since this is not something we want to add at this time. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The files /docker-entrypoint-updatedb.d/* are run every time a container starts, even if the database directory is not empty. This is unlike the files /docker-entrypoint-initdb.d/*, which are only run if the database directory is empty. When the database directory is empty, the update scripts are run after the init scripts.
Suppose that the following files are present in a container image:
When a new container is run for the first time with a persistent volume, for example as follows:
the following init files are run, in this order:
If the container is stopped and a new container is started with the same command, only this file is run:
If the directory
/docker-entrypoint-updatedb.dis not present in the image, there are no changes in behavior.