MariaDB 11 도커 이미지 헬스체크 이슈

2023/6/27부터 MariaDB 11.0 도커 이미지에 mysqladmin이 빠져 docker compose에서 헬스체크가 실패하는 문제가 있다
mariadb:
image: mariadb
restart: always
volumes:
- './mariadb/:/var/lib/mysql/'
healthcheck:
test: ["CMD", "mysqladmin", "ping", "--silent"]
기존에 많이 쓰던 헬스체크 방식
기존에는 보통 mysqladmin ping
으로 헬스체크를 했다
mysqladmin을 뺀 이유
MariaDB Server Docker Official Images Healthcheck without mysqladmin - MariaDB.org
MariaDB Server 11.0 got released as a stable Docker Official Image recently a number of people where surprised by the removal of the mysql named executables

mysqladmin을 이용한 헬스체크의 가장 큰 문제는 DB 초기화 시(mariadb-install-db
) 또는 /docker-entrypoint-initdb.d
초기화 과정, 또는 MARIADB_AUTO_UPGRADE=1
을 이용한 db 업그레이드시 헬스체크가 성공하는 문제가 있다고 한다
위 세가지 경우는 나중에 --skip-networking
옵션을 떼고 재시작을 하기 때문에 healthy로 인식되면 안된다고 한다
Using Healthcheck.sh script
healtcheck.sh

mysqladmin 대신에 healthcheck.sh 스크립트가 추가됐고 이걸 사용하는 쪽으로 가이드하고 있다
ex) github actions
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
github actions에서 docker compose로 mariadb 컨테이너를 띄우는 경우 헬스체크 커맨드는 위처럼 작성하면 된다
참고
latest tag 1:11.0.2+maria~ubu2204 - mysql command is gone · Issue #512 · MariaDB/mariadb-docker
Hello mysql command is not working in latest iteration of mariadb. Is this on purpose ? Thanks