Extending docker-entrypoint.sh

How can I extend the functionality of docker-entrypoint.sh for an additional initial SQL script directory to run each time I start a mariadb docker container?

By now, I'm only able to do

  • an initial script automation in /docker-entrypoint-initdb.d/ subdir
  • start a single initial stript by using the --init-file parameter in mariadbd

As far as I know, I need another Entrypoint script that's loading the docker-entrypoint.sh via source command and somehow the functions docker_temp_server_start,docker_temp_server_stop and docker_process_init_files (maybe starting under mysql user)

But it's always crashing with

  • missing mariadbd command before the parameters resulting in "/usr/local/bin/docker-entrypoint.sh: line 122: --skip-networking: command not found",
  • the mariadbd is not running before executing the initial custom scripts
  • mariadb database environment isn't initially setup

Modifying docker-entrypoint.sh would work but is not sustainable against newer mariadb versions with modified docker-entrypoint.sh scripts. Concatenating all SQL files before could get you into trouble of file sizing one day and more difficult debugging issues.

Answer Answered by Daniel Black in this comment.

Hi, its an outstanding feature request, and you've probably seen https://github.com/MariaDB/mariadb-docker/issues/515. Seems Docker Library people currently want to take your current approach.

You'd need to effectively add source oldentrypoint.sh, and copy most of _main to your entrypoint with changes to run each time it starts.

There probably be large simplifications of this by requesting the original wrapping initialization up into its own function. Feel free to make those non-impacting changes as a pull request - https://github.com/MariaDB/mariadb-docker.

Adding intialization based on mariadb-backups (https://github.com/MariaDB/mariadb-docker/issues/522#issuecomment-1647045650) is going to be another largish change so having intialization in a separate function is going be easier to maintain compatibility.

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.