MySql in docker - common issues
The problem:
Before the database container is loaded, the application wants to execute some query to the DB. Typically, this is related to migrations when creating a completely new project instance. Since the database does not respond, the application container is killed.
The solution?
A simple solution is to add HealthCheck to the DB ping and add a dependency (depends_on) in the application container if the database container is healthy.
An example
HealthCheck
Is added to a db service
Dependency
It is added to the application service.
The result
The resulting "trimmed" docker-compose:
✖