How do I know when my docker mysql container is up and mysql is ready for taking queries?

You can install mysql-client package and use mysqladmin to ping target server. Useful when working with multiple docker container. Combine with sleep and create a simple wait-loop:

while ! mysqladmin ping -h"$DB_HOST" --silent; do
    sleep 1
done

Leave a Comment