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.
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
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 options: --health-cmd="healthcheck.sh --su-mysql --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-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_sqlfunction of the entrypoint to perform the initialization;
mariadbhas 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.
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 options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3