MariaDB Server Docker Official Images Healthcheck without mysqladmin
MariaDB Server 11.0 was recently released and its Docker Official Image didn’t include mysqladmin
which broke the healthcheck in a few usage scenarios. This surprised some people in the change of behaviour. We have observed a number uses of the mysql names in containers, custom healthchecks and some /docker-entrypoint-initdb.d
scripts. To help use these correctly, lets talk about what is available in the containers to help perform healthcheck and initialization functions.
On healthchecks, HEALTHCHECK
isn’t there in Docker Official Images (for reasons), however the MariaDB Server container does have a healthcheck.sh script. A common theme in the 11.0 / latest release was the missing mysqladmin
executable being used in healthcheck scripts. From what has been seen, the common healthcheck is mysqladmin ping
, but this has a problem in the container. The biggest problem is a healthcheck is it will return success during database initialization (mariadb-install-db
), or during the /docker-entrypoint-initdb.d
initialization, or during the MARIADB_AUTO_UPGRADE=1
. After running these 3 points the entrypoint will abruptly shutdown the server to start it up again without --skip-networking
. Those that used --protocol=tcp
with mysqladmin
/ mariadb-admin
will have some success as healthcheck.
A simple use of the healthcheck.sh script usage in a GitHub Actions will look like:
services:
mariadb:
image: mariadb:latest
env:
MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: true
MARIADB_MYSQL_LOCALHOST_USER: 1
MARIADB_MYSQL_LOCALHOST_GRANTS: USAGE
ports:
- 3306
healthcheck:
test: [ "CMD", "healthcheck.sh", "--su-mysql", "--connect", "--innodb_initialized" ]
start_period: 1m
start_interval: 10s
interval: 1m
timeout: 5s
retries: 3
There is currently one bug that requires an empty root password for the container logs to not fill up with authentication errors. This is due to the --connect
check, which is has a solution in progress.
If initializing the database with a script in /docker-entrypoint-initdb.d
there are a few alternatives:
- Just use a SQL file, any filename ending in .sql, or .sql.gz, .sql.xz, .sql.zst (for compressed files);
- Use a bash script, ending in .sh, but without execute permissions and the
docker_process_sql
function of the entrypoint to perform the initialization; mariadb
has been the command line client since 10.4 and is available in all maintained containers.
Since taking care of the day to day maintenance of the Docker Official Images of MariaDB Server there have been server release notes detailing changes in the container images too.
Thank you for using MariaDB Server containers. Please report issues on GitHub or JIRA.
Edit:
The previous bug is now fixed and released. A healthcheck
user is created on new installations enabling a simpler compose file like:
services:
mariadb:
image: mariadb:latest
env:
MARIADB_ROOT_PASSWORD: sosecretonthiswebpage
ports:
- 3306
healthcheck:
test: [ "CMD", "healthcheck.sh", "--connect", "--innodb_initialized" ]
start_period: 1m
start_interval: 10s
interval: 1m
timeout: 5s
retries: 3
you saved my day.
I was missing “mariadb-admin” part.
Thanks for such nice explanation. have nice time!!