I am trying to implement this exact solution but the health check refuses to work.
Docker File:
version: "3"
services:
mariadb:
container_name: maria-db
image: jsurf/rpi-mariadb
restart: unless-stopped
ports:
- 3306:3306
secrets:
- mariadb-root-password
- mariadb-ha-database
- mariadb-ha-username
- mariadb-ha-password
environment:
- MYSQL_ROOT_PASSWORD=/run/secrets/mariadb-root-password
- MYSQL_DATABASE=/run/secrets/mariadb-ha-database
- MYSQL_USER=/run/secrets/mariadb-ha-username
- MYSQL_PASSWORD=/run/secrets/mariadb-ha-password
volumes:
- ./mounts/mariadb:/var/lib/mysql
healthcheck:
test: ["CMD", "mysql", "--user=root", "--password=$$(cat $$MYSQL_ROOT_PASSWORD)", "-e 'show databases'"]
interval: 10s
timeout: 2s
retries: 1
secrets:
mariadb-root-password:
file: ./.secrets/mariadb-root-password.txt
mariadb-ha-database:
file: ./.secrets/mariadb-ha-database.txt
mariadb-ha-username:
file: ./.secrets/mariadb-ha-username.txt
mariadb-ha-password:
file: ./.secrets/mariadb-ha-password.txt
When running the health check on the container:
root@a288e9ba9f2b:/# mysql --user=root --password=$(cat $MYSQL_ROOT_PASSWORD) -e 'show databases'
+--------------------+
| Database |
+--------------------+
| homeassistant |
| information_schema |
| mysql |
| performance_schema |
+--------------------+
However the container is always shown as unhealthy:

I must be missing something super simple, right?