-
Notifications
You must be signed in to change notification settings - Fork 446
Implement HEALTHCHECK instruction #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
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? |
docker-library/cassandra#76 (comment) has some good points regarding adding default health checks to official images 👍 (https://github.com/docker-library/healthcheck also has copies of several images with reasonably-generic |
Current stance is still the same as linked above in cassandra.
Closing old issue. |
This' how is made it
|
Pay attention, if you use the |
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 |
FYI, it looks like there's now a healthcheck script built into the image, it's just not called in the Dockerfile for some reason. You can enable it like so:
For more details, and additional tests that can be enabled, see https://github.com/MariaDB/mariadb-docker/blob/master/healthcheck.sh IMO this (or something similar) should be enabled by default. I'm a firm believer in setting reasonable defaults, and I don't think external services failing to start because docker-compose has no way of checking whether the service is healthy qualifies as "reasonable".
Users can customize the health check command if they want to. That's not a good reason for the default behavior to be "no health checks at all; just fail silently and don't give the container engine any indication that the service is unhealthy".
Okay. Again, that's not an argument for not having a basic healthcheck by default. If users want something more comprehensive than what Docker's internal health check mechanism can provide then they can always write it themselves.
All the more reason for those official images to have a proper health check predefined, so users don't try to write their own health check and discover that behavior the hard way. In images where it's applicable the default health check should detect "localhost only mode" and react appropriately. If programing that is too much effort for some reason, then leave out the health check on the images where that's a problem, and include a note about why. That'd be disappointing, but no worse than the current status quo.
It's a healthcheck, not a stress test. A simple healthcheck script running twice a minute should not impose any significant additional load on a system. If for whatever reason the user wants something more complicated that is resource intensive, then let them enable that themselves so they're aware of the trade-off. |
This is wrong, please edit your reply to not induce others into error. If you do this, it will do the ping with
As you can see, the access was denied, but the exit status code was still 0! You need to specify the root password to use that command. For instance, if your root password is 123:
|
@Luc45 Ping just checks the connection, not whether your credentials are correct. It will exit with 1 if the server is not running, which might be good enough depending on your goal. If you need something more complicated than that, see the example in my previous comment. |
When I use these settings, the healthcheck test result for option --connect is correctly reported but I get a warning in my logs every time the healthcheck.sh script is run :
Samely, if I enter the following command, the same warning is thrown in my docker compose logs and in my console :
but this would not throw the warning:
Is that something which is expected or is there something wrong with my setup ? |
Its possible to hide these with log_warnings=1. I maybe think I'll just expand the Thanks for your comment @jerdoe. Nothing is really wrong with your setup. Creating new issues is ok too. |
I too see
on the logs, and ended up on this thread. |
yep, started working on it in #430, I haven't overcome all cases yet, for the moment |
Yes, saw it - thank you. |
For whoever it may concern, I ended up doing it like this: services:
db:
healthcheck:
test: ["CMD-SHELL", "mysql dbname -udbuser -pdbpass -e 'SELECT 1;' || exit 1"]
interval: 2s
retries: 120
php:
depends_on:
db:
condition: service_healthy The healthcheck will only pass when a |
@Luc45 watch out, the initialization starts a temporary server on initialization and upgrades. Its possible this healthcheck will succeed when its in a getting ready stage. While I haven't implemented user and pass on a command line, there are configuration files that can be passed that can contain:
And then: |
@grooverdan Thanks for that previous comment, suggesting the use of a custom I can now use the following healthcheck command and it works perfectly for both tests with no warnings.
With this, there is also no need to set the Thanks! |
If you have secrets and environment variables, you could also do this.
|
Thanks, this one was the only working option on my side. |
ack. Yes I do need to do something better. |
MySQL Documentation says about mysqladmin ping Check whether the server is available. The return status from mysqladmin is 0 if the server is running, 1 if it is not. This is 0 even in case of an error such as Access denied, because this means that the server is running but refused the connection, which is different from the server not running. |
@grooverdan @monkeyhybrid can you elaborate your answer a bit more? Same problem here, lot of warnings due to the healthcheck script. |
If i use healthcheck:
test: ["CMD-SHELL", "mysqladmin ping -P 3306 -p MyRootPW | grep 'mysqld is alive' || exit 1"]
interval: 2s
retries: 15 just to ping my db, i got status unhealthy with log any help? |
Using MariaDB 11.0.2 in Docker I am very curious that nothing mentioned here works. If I try to execute I have set And last but not least: Is something wrong with my permissions? |
Like the SO, I don't know what causes "failed switching to "mysql": operation not permitted". More information on the OS / Docker version might be applicable here.
"Could not open required defaults file: /etc/mysql/healthcheck.cnf-notdefault" - looks like you haven't passed this file into the container as a volume. I was updating https://mariadb.com/kb/en/using-healthcheck-sh-script/ today and drafting a blog about the removal of mysql/mysqladmin that was in the release notes. Please create a new issue for bugs. Keeping track of old threads where the situation has changed significantly is difficult. |
Yesterday I rebuilt my containers and health check also stopped work. The problem was that on latest mariadb containers command Doesnt work:
Fix:
docker-compose.yml
Dockerfile
|
Set the
|
I resolve this issue by using a GA(General Availability) version of mariadb. In my case
HealthCheck is now healthy. |
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?
The text was updated successfully, but these errors were encountered: