When building a mysql container from docker-compose, once built is complete mysql takes few seconds before it comes alive. During this time I have a script that runs laravel migration. However it is impossible to connect to mysql for few seconds as it is still connecting (not sure exactly what it is doing).
To fix that I added in my script a sleep 30 which pauses for 30s while it waits for mysql container to fully come up live.
I dont like this work around as it doesnt really fix the problem, what if next time I build the container it takes 31s? then the laravel migration would still fail.
Has anyone has this problem migrating a fresh (just booted) mysql database container? any ideas how I could fix this?