How can I make Docker Compose wait until MySQL is ready?

August 19, 2026 0 answers
Asked by puzzle-box14
I'm following a Docker getting-started workshop and ran into a startup race while using Docker Compose. The application container starts before MySQL has finished initializing, so it repeatedly waits for mysql:3306 and eventually fails with an ECONNREFUSED error. If I run docker compose down and then bring everything back up, it works because the database has already been initialized. Is this expected, and what is the recommended way to ensure the application only starts connecting after MySQL is ready?

Answers

Add your answer

Answers are reviewed before publication.

Related Discussions