MariaDB / mariadb-docker

Docker Official Image packaging for MariaDB
https://mariadb.org
GNU General Public License v2.0
759 stars 438 forks source link

Trying to override docker-entrypoint.sh sourcing original one fails #452

Closed typoworx-de closed 2 years ago

typoworx-de commented 2 years ago

I'm trying to override docker-entrypoint.sh to implement a feature being able to import sql-patches (not initdb).

my script looks like this and I'm overriding entrypoint in my docker-compose.yml

docker-compose.overrides.yml

version: '3.6'

services:
  db:
    entrypoint: bash /root/bin/custom-entrypoint.sh
  volumes:
    - ./docker/db/bin/:/root/bin

/root/bin/custom-entrypoint.sh (inside container)

#!/bin/bash

echo "Running entrypoint $0"

source /docker-entrypoint.sh
_main "$@"

# custom stuff goes here

Restarting the stack results in the following error in the new entrypoint:

_main command not found

It looks like the source'ing is somehow ignored for my own entrypoint script.

Is there any draft how to properly do this? I think the last line in the original-entrypoint in this project already proposes a draft on how to use it, but for some reason the functions of this script are not sourced/imported in the custom entrypoint :-/

yosifkit commented 2 years ago
  1. add a set -e and you'll see it is failing at the source /docker-entrypoint.sh line
  2. Replacing entrypoint likely resets command too, so you need to also supply that for "$@" to work as expected
  3. Just running _main is probably not going to do what you want as it ends in basically exec mysqld and so will never return to your script to run anything else.
grooverdan commented 2 years ago

The location of the entrypoint script isn't what you expected.

$ podman run --rm -ti mariadb:10.6 find . -name docker-entrypoint.sh
./usr/local/bin/docker-entrypoint.sh