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

Run scripts on each startup #882

Closed
jonasgroenke opened this issue Jul 8, 2022 · 1 comment
Closed

Run scripts on each startup #882

jonasgroenke opened this issue Jul 8, 2022 · 1 comment
Labels
question Usability question, not directly related to an error with the image

Comments

@jonasgroenke
Copy link

jonasgroenke commented Jul 8, 2022

Hey, can we add a possibility for scripts which are executed on every startup? Not only on initializing the database.

My use case is that I have init scripts which are creating some users specified in the secret files.
When I now change the passwords in the secrets, I have to completely remove the database just for updating the passwords.
Or do I miss something and there is already something for my use case?

My current solution is to add a custom entrypoint and call some methods from the official one. But other people might be also interested in and we can improve it.

#!/bin/bash
set -e
source /usr/local/bin/docker-entrypoint.sh

docker_setup_env "$@"

if [ "$(id -u)" = "0" ]; then
  mysql_note "Switching to dedicated user 'mysql'"
  exec gosu mysql "$BASH_SOURCE" "$@"
fi

mysql_note "Starting temporary server"
docker_temp_server_start "$@"
mysql_note "Temporary server started."

# Set mysql passwords from secrets
docker_process_init_files /docker-entrypoint-initdb.d/01-create-user.sh

mysql_note "Stopping temporary server"
docker_temp_server_stop
mysql_note "Temporary server stopped"

exec "$@"`
@wglambert wglambert added the question Usability question, not directly related to an error with the image label Jul 8, 2022
@wglambert
Copy link

Duplicate of #642 (comment)

See MariaDB/mariadb-docker#284 (comment)

@tianon tianon closed this as completed Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Usability question, not directly related to an error with the image
Projects
None yet
Development

No branches or pull requests

3 participants