There is a new Dockerfile instruction HEALTHCHECK what is useful for detecting if container is still starting (and other should wait) or unhealthy.
It it enought to write something like this?
HEALTHCHECK CMD mysql --user=$MYSQL_USER --password=$MYSQL_PASSWORD -e "show databases;"
Maybe to make it working also if MYSQL_USER or MYSQL_PASSWORD is not filled → use root. Then if MYSQL_ALLOW_EMPTY_PASSWORD and other related settings.
Any ideas?
https://github.com/docker-library/cassandra/pull/76#issuecomment-246054271 has some good points regarding adding default health checks to official images :+1:
(https://github.com/docker-library/healthcheck also has copies of several images with reasonably-generic HEALTHCHECK instructions added)
Current stance is still the same as linked above in cassandra.
I do not feel that generalized healthchecks on the official images are really that useful.
- users will have their own idea of what is "healthy"
- it does not actually test that the service is listening to connections outside of
localhost(see https://github.com/docker-library/healthcheck for some examples that do more than what's proposed here, including attempting to check whether the service is listening remotely)
- some of the Official Images even purposely start in a
localhostonly mode for database initialization and then kill and start the main service with full network availability
- after upgrading their images, current users will have extra unexpected load on their systems for healthchecks they don't necessarily need/want and may be unaware of
Closing old issue.
This' how is made it
mariadb:
image: mariadb
restart: always
volumes:
- './mariadb/:/var/lib/mysql/'
healthcheck:
test: ["CMD", "mysqladmin", "ping", "--silent"]
Pay attention, if you use the /docker-entrypoint-initdb.d folder to run some SQL scripts at runtime, it may be useful to test if data is ready instead of just the server.
Pay attention, if you use the
/docker-entrypoint-initdb.dfolder to run some SQL scripts at runtime, it may be useful to test if data is ready instead of just the server.
That's an issue. Can we reopen this issue? If you have entrypoint sql or sh, the healthcheck from @SalathielGenese does not work
ideas welcome - https://jira.mariadb.org/browse/MDEV-25434
Most helpful comment
This' how is made it
mariadb: image: mariadb restart: always volumes: - './mariadb/:/var/lib/mysql/' healthcheck: test: ["CMD", "mysqladmin", "ping", "--silent"]