Add MYSQL_INIT_ONLY var to exit after init #423
Closed
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.
One of the things I use the mysql image for is bind-mounting a dump into
/docker-entrypoint-initdb.d/
to restore a database. The database restore happens, mysql starts up, and everything is happy. However, I usually don't want to leave the dump bind-mounted into the container permanently. Once the database has been restored, I often want to stop the container, remove the dump file, and then worry about the full deployment of the service at some later stage.However, the current
docker-entrypoint.sh
always starts mysql after the init process. If we perform a database restore as part of the init, there isn't anything to signal when a restore is complete so that the container can be shut down. So my workaround up until now has been to also bind-mount a shell script to run after the database restore. (The "signal" can be just touching the file/var/lib/mysql/restore.done
, for example. When the file exists, our orchestration stuff knows the database has been restored and can stop/rm the container.)This change skirts the whole issue by providing a way to tell the container to exit once all initialization is done. If there's some other less obvious way to do the same thing, I'm all ears as I haven't seen it yet.
I will submit a PR to update the docs if consensus is that this isn't a stupid idea.
If this is accepted, I will likely propose the same feature for the mariadb and postgres images as well.