Bird
0
0

You want to add a monitoring sidecar container to your existing app without changing the app code. Which approach best follows the sidecar pattern?

hard📝 Best Practice Q15 of 15
Docker - Production Patterns
You want to add a monitoring sidecar container to your existing app without changing the app code. Which approach best follows the sidecar pattern?
AAdd a new service in your Docker Compose file that runs the monitoring container sharing the app's network and volumes
BModify the app container image to include monitoring tools inside it
CRun the monitoring container separately on another host
DAdd monitoring commands inside the app's Dockerfile entrypoint script
Step-by-Step Solution
Solution:
  1. Step 1: Understand sidecar pattern goal

    The sidecar pattern adds features by running helper containers alongside the main app without modifying the app itself.
  2. Step 2: Evaluate options for adding monitoring

    Adding a new service in Compose that shares network and volumes with the app fits the sidecar pattern perfectly.
  3. Step 3: Exclude options that modify app or separate hosts

    Modifying app image or running monitoring separately breaks sidecar principles.
  4. Final Answer:

    Add a new service in your Docker Compose file that runs the monitoring container sharing the app's network and volumes -> Option A
  5. Quick Check:

    Sidecar = helper container alongside app, no app code change [OK]
Quick Trick: Sidecar means add helper container, no app code change [OK]
Common Mistakes:
  • Modifying app image instead of adding sidecar
  • Running monitoring on separate host breaks sidecar
  • Embedding monitoring commands inside app entrypoint

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes