Skip to content

2025-05-31 mariadb - master branch - PR 1 of 2 #804

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Paraphraser
Copy link

When I filed
docker-mariadb issue 163 I had hoped for a fairly quick fix.

The problem (for IOTstack) is not so much about the root password not being set on newly-initialised mariadb containers but how mariadb commands react when the root password has not been set.

In particular, the IOTstackBackup routines that handle instances of MariaDB trigger backups like this:

docker exec mariadb bash -c mariadb-dump --single-transaction -p\$MYSQL_ROOT_PASSWORD \$MYSQL_DATABASE >/backup/backup.sql"

That command will fail if the root password was not set when the persistent store was initialised. Unless the user notices the resulting log message and interprets it correctly, the user will likely assume that database backups are occurring when, in fact, they are not.

This problem affects gitea, nextcloud and wordpress, as well as pure instances of mariadb.

The "solution" proposed here is to leverage the existing cron periodic jobs structure inside mariadb containers. Every 15 minutes a script will run to check whether the root password has been set, and set it if it has not been. The body of the script really only runs once per container launch, thereafter sensing it has already run and taking an early exit.

This strategy will continue to work once Issue 163 is resolved. It will just become a no-op which can be removed safely at a later date. The approach is also unlikely to interfere with however a fix for Issue 163 is implemented.

The Gitea documentation has been updated to remove the "how to" instructions which only worked for that container-pair, in favour of this solution which will work for all relevant containers.

When I filed
[docker-mariadb issue 163](linuxserver/docker-mariadb#163)
I had hoped for a fairly quick fix.

The problem (for IOTstack) is not so much about the root password not
being set on newly-initialised mariadb containers but how mariadb
commands react when the root password has not been set.

In particular, the IOTstackBackup routines that handle instances of
MariaDB trigger backups like this:

```
docker exec mariadb bash -c mariadb-dump --single-transaction -p\$MYSQL_ROOT_PASSWORD \$MYSQL_DATABASE >/backup/backup.sql"
```

That command will fail if the root password was not set when the
persistent store was initialised. Unless the user notices the
resulting log message and interprets it correctly, the user will likely
assume that database backups are occurring when, in fact, they are not.

This problem affects gitea, nextcloud and wordpress, as well as pure
instances of mariadb.

The "solution" proposed here is to leverage the existing `cron` periodic
jobs structure inside mariadb containers. Every 15 minutes a script will
run to check whether the root password has been set, and set it if it
has not been. The body of the script really only runs once per container
launch, thereafter sensing it has already run and taking an early exit.

This strategy will continue to work once Issue 163 is resolved. It will
just become a no-op which can be removed safely at a later date. The
approach is also unlikely to interfere with however a fix for Issue 163
is implemented.

The Gitea documentation has been updated to remove the "how to"
instructions which only worked for *that* container-pair, in favour of
this solution which will work for *all* relevant containers.

Signed-off-by: Phill Kelley <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant