I am trying to make sure that my app container does not run migrations / start until the db container is started and READY TO accept connections.
So I decided to use
I modified the docker-compose.yml
as per the following example and it worked.
mysql:
image: mysql:5.6
ports:
- "3306:3306"
volumes:
# Preload files for data
- ../schemaAndSeedData:/docker-entrypoint-initdb.d
environment:
MYSQL_ROOT_PASSWORD: rootPass
MYSQL_DATABASE: DefaultDB
MYSQL_USER: usr
MYSQL_PASSWORD: usr
healthcheck:
test: mysql --user=root --password=rootPass -e 'Design your own check script ' LastSchema
In my case ../schemaAndSeedData
contains multiple schema and data seeding sql files. Design your own check script
can be similar to following select * from LastSchema.LastDBInsert
.
While web dependent container code was
depends_on:
mysql:
condition: service_healthy