Bird
0
0

Given this Docker Compose snippet, what will happen when you run docker-compose up?

medium📝 Command Output Q13 of 15
Docker - Production Patterns
Given this Docker Compose snippet, what will happen when you run docker-compose up?
version: '3'
services:
  app:
    image: myapp:latest
  logger:
    image: logcollector:latest
    depends_on:
      - app
AOnly <code>app</code> container starts; <code>logger</code> is ignored
B<code>logger</code> starts before <code>app</code> container
CBoth <code>app</code> and <code>logger</code> containers start; <code>logger</code> waits for <code>app</code> to start first
DDocker Compose throws an error due to missing networks
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the Compose file services and dependencies

    There are two services: app and logger. The logger service depends on app.
  2. Step 2: Understand depends_on behavior

    depends_on ensures app starts before logger, but both start when running docker-compose up.
  3. Final Answer:

    Both app and logger containers start; logger waits for app to start first -> Option C
  4. Quick Check:

    depends_on means start order, both containers run [OK]
Quick Trick: depends_on controls start order, not exclusion [OK]
Common Mistakes:
  • Thinking depends_on skips starting dependent container
  • Assuming logger starts before app
  • Expecting error due to missing networks (default network is created)

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes