Skip to content
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

Add support for database update scripts. #673

Closed
wants to merge 1 commit into from

Conversation

ogheorghies
Copy link

@ogheorghies ogheorghies commented Feb 9, 2020

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:

/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

If the directory /docker-entrypoint-updatedb.d is not present in the image, there are no changes in behavior.

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
@yosifkit
Copy link
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants