0
0
Dockerdevops~5 mins

Depends_on for service ordering in Docker - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of depends_on in a Docker Compose file?

depends_on defines the order in which services start. It ensures that a service starts only after the services it depends on have started.

Click to reveal answer
intermediate
Does depends_on guarantee that a service is ready to use before starting the dependent service?

No. depends_on only controls start order, not readiness. Services might start but not be fully ready.

Click to reveal answer
beginner
How do you specify that web service depends on db service in Docker Compose?
services: web: depends_on: - db
Click to reveal answer
intermediate
What is a limitation of depends_on in Docker Compose?

By default, depends_on does not wait for services to be "ready". It only waits for containers to start. (In v2.1+, use condition: service_healthy to wait for healthchecks.)

Click to reveal answer
intermediate
What can you use to ensure a service is ready before starting another, since depends_on does not check readiness?

You can use healthchecks and scripts that wait for a service to be ready before starting the dependent service.

Click to reveal answer
What does depends_on control in Docker Compose?
AThe environment variables
BThe network ports used
CThe container image versions
DThe order services start
Does depends_on wait for a service to be fully ready before starting another service?
ANo, it only waits for the container to start
BYes, always
COnly in Docker Compose version 2
DOnly if healthchecks are defined
How do you declare that service app depends on service db?
Aapp: depends_on: - db
Bapp: depends_on: db
Capp: depends: db
Dapp: depends: - db
Which Docker Compose version introduced support for depends_on conditions (like service_healthy) regarding service readiness?
AVersion 1
BVersion 2
CVersion 4
DVersion 3
What is a common method to ensure a service is ready before starting another service?
AUse <code>depends_on</code> only
BRestart the Docker daemon
CUse healthchecks and wait scripts
DUse environment variables
Explain how depends_on works in Docker Compose and its limitations.
Think about what <code>depends_on</code> guarantees and what it does not.
You got /4 concepts.
    Describe how you would ensure a database service is ready before starting a web service in Docker Compose.
    Consider combining Docker Compose features and scripts.
    You got /4 concepts.