-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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 a feature to shtudown container after running init scripts #357
Comments
Why not just make your script alphabetically after your backup file in #!/bin/bash
set -e
# you should have access to any vars from the entrypoint since scripts are sourced
kill -s TERM "$pid"
wait "$pid"
# or
killall -s TERM mysqld
sleep 10
# prevent entrypoint from continuing
exit 1 |
The solution documented in this issue no longer works ( Are there plans to support this now that #471 is merged? |
You should be able to invoke |
Also, with #471 you could more easily write your own script which just does the initialization followed by exiting (and thus be much less error-prone). |
A script that copies |
Maybe I'm confused and there's an easier way to go about this? |
I'm not sure if this works for everyone else interested - but I have since found a clean solution for my needs: I simply append the SQL https://dev.mysql.com/doc/refman/5.7/en/shutdown.html As far as I'm concerned, this is a good solution. If there are no objections, I think it's safe to close this issue? |
I try this one out today, thanks! |
Works as intended for my use case; this should be the recommended solution |
This is the command I run at the end of my bootstrap script:
But, the container does not shut down and I see this error in the logs:
What am I doing wrong? |
@marzigolbaz, you probably just need an mysql/.template.Debian/docker-entrypoint.sh Lines 355 to 365 in d284e15
mysql/.template.Debian/docker-entrypoint.sh Lines 119 to 123 in d284e15
Since the init scripts are sourced:
You can just use the provided function to shut it down: #!/bin/bash
# all your initialization steps...
docker_temp_server_stop
exit 0 |
@yosifkit thank you so much for your detailed clarification. Adding exit 0 fixed the issue. Thanks again. |
Closing old issue. Customization like this is supported by allowing users to source the entrypoint script (for example #423 (comment)). |
I wasted half of the day finding the proper way to achieve initialisation and exit.
I am really wondering why cant we move last line in mysql/8.0/docker-entrypoint.sh Line 400 in 48f07e3
to the last part of the file, like this:
So then anyone can just run container with something like
|
For those who get in there, here is mine example of init scipt I am using, maybe it will be useful:
By the way, with my proposal above it must be as easy as
|
I just removed the line |
Sometimes I use a command like the following to initialize a mysql new database volume from a backup.
It would be handy if I could (through a environment variable, alternative entrypoint, etc.) cause the docker container to stop running after the init process is complete, instead of listening for connections.
My current workaround (hack) is to build a new image based on the mysql image, that contains a shell script that waits for the init process to finish - and then kill the mysql service. This seems to work fine, but it would be nice if there was a baked in way to accomplish this behavior.
The text was updated successfully, but these errors were encountered: