Add "mysql"
This commit is contained in:
parent
a5e5a6e9f3
commit
03337f3473
|
|
@ -0,0 +1,5 @@
|
|||
FROM mysql
|
||||
|
||||
COPY docker-healthcheck /usr/local/bin/
|
||||
|
||||
HEALTHCHECK CMD ["docker-healthcheck"]
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
#!/bin/bash
|
||||
set -eo pipefail
|
||||
|
||||
if [ "$MYSQL_RANDOM_ROOT_PASSWORD" ] && [ -z "$MYSQL_USER" ] && [ -z "$MYSQL_PASSWORD" ]; then
|
||||
# there's no way we can guess what the random MySQL password was
|
||||
echo >&2 'healthcheck error: cannot determine random root password (and MYSQL_USER and MYSQL_PASSWORD were not set)'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
user="${MYSQL_USER:-root}"
|
||||
|
||||
export MYSQL_PWD="${MYSQL_PASSWORD:-$MYSQL_ROOT_PASSWORD}"
|
||||
|
||||
args=(
|
||||
# force mysql to not use the local "mysqld.sock" (test "external" connectibility)
|
||||
-h"$(hostname --ip-address || echo '127.0.0.1')"
|
||||
-u"$user"
|
||||
--silent
|
||||
)
|
||||
|
||||
if select="$(echo 'SELECT 1' | mysql "${args[@]}")" && [ "$select" = '1' ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# If the probe returns 2 ("starting") when the container has already moved out of the "starting" state then it is treated as "unhealthy" instead.
|
||||
# https://github.com/docker/docker/blob/dcc65376bac8e73bb5930fce4cddc2350bb7baa2/docs/reference/builder.md#healthcheck
|
||||
exit 2
|
||||
Loading…
Reference in New Issue