Depends_on version 3

Hi,

Docker version: 1.13.1
Compose Version: 1.11.2
Platform: mac

Looking to use the depends_on functionality to refer to a healthcheck in another service e.g.

depends_on:
  config-service-v1:
    condition: service_healthy

If I set the compose file version to “3” I get “.depends_on contains an invalid type, it should be an array” if I set the version back to “2.1” it works. Is version 3 not backward compatible or has the depends_on syntax changed for version 3?

I also tried specifying the depends_on as an array e.g.

depends_on:
  - config-service-v1:
      condition: service_healthy

This resulted in a different error.

Kind regards,
Rob.

“No longer supports the condition”

Meanwhile, it seems it’s supported again. The Compose 3.9 specification documents this as the “long syntax”:

Long syntax

The long form syntax enables the configuration of additional fields that can’t be expressed in the short form.

  • condition: condition under which dependency is considered satisfied
    • service_started: is an equivalent of the short syntax described above
    • service_healthy: specifies that a dependency is expected to be “healthy” (as indicated by healthcheck) before starting a dependent service.
    • service_completed_successfully: specifies that a dependency is expected to run to successful completion before starting a dependent service.

Also, a January 2021 Apache Airflow example uses it. (I’ve not validated that example.)

This may need version: 3.9.