liveBook · Manning

Depends_on

As explained in Learn Docker in a Month of Lunches, Second Edition

depends_on is a Docker Compose file property that declares startup dependencies between services.

Use depends_on in a Docker Compose service definition when one service must start after other services. Compose starts the listed dependencies before starting the dependent service. section 7.2

Listing 7.2 Compose services for the multi-container app
accesslog:
  image: diamol/ch04-access-log:2e

iotd:
  image: diamol/ch04-image-of-the-day:2e
  ports:
    - "80"

image-gallery:
  image: diamol/ch04-image-gallery:2e
  ports:
    - "8010:80"
  depends_on:
    - accesslog
    - iotd

See the multi-container Compose definition where image-gallery depends on accesslog and iotd. section 7.2

Apply the dependency in a runnable Compose workflow:

  • Declare the required service names under depends_on. section 7.2
  • Start the application with docker compose up --detach. section 7.2
  • Verify that dependencies start before the dependent service and browse the application on its published host port. section 7.2

How Learn Docker in a Month of Lunches, Second Edition covers it

How deep it goes
Defines a service-name list and demonstrates resulting startup order, without detailing dependency health checks or readiness.
Examples
Uses image-gallery depending on accesslog and iotd, then runs docker compose up --detach.
What it assumes
Assumes Docker Compose service definitions and a multi-container application context.
What you can do after
Operate/configure Docker Compose startup ordering for dependent application services.
How it connects
Connects Docker Compose services, multi-container applications, published ports, and application startup.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Docker in a Month of Lunches, Second Edition. The section links point to the parts of the book it draws on.