How to Ensure Service Containers Start After Primary Containers Are Ready

How to Ensure Service Containers Start After Primary Containers Are Ready

just add "condition: service_healthy" to depends_on services

app:
    <snip>
    depends_on:
        db:
            condition: service_healthy
db:
    <snip>
    healthcheck:
        <snip>

It's useful when some services take a little bit longer time to get ready after the container starts like database services (i.e MySQL). so we make sure our app runs right after they get ready (which is tested by healthcheck).

In the previous article, i listed container startup controllers. you can read it from here: Docker Container Startup Controll