Bird
0
0

How can you monitor Docker events and save only container creation and destruction events to a file named events.log?

hard📝 Workflow Q9 of 15
Docker - Logging and Monitoring
How can you monitor Docker events and save only container creation and destruction events to a file named events.log?
Adocker events --filter event=create --filter event=destroy | tee events.log
Bdocker events --filter event=create,destroy > events.log
Cdocker events --filter event=create --filter event=destroy > events.log
Ddocker events --filter event=create --filter event=destroy --output events.log
Step-by-Step Solution
Solution:
  1. Step 1: Understand event filtering and output redirection

    Multiple --filter event= flags filter create and destroy events. Output redirection with > overwrites file but does not show output.
  2. Step 2: Evaluate options for saving and viewing output

    docker events --filter event=create --filter event=destroy | tee events.log uses pipe to tee, which saves output to file and shows it live. docker events --filter event=create --filter event=destroy > events.log overwrites file but no live output. docker events --filter event=create,destroy > events.log uses invalid combined filter. docker events --filter event=create --filter event=destroy --output events.log uses unsupported --output flag.
  3. Final Answer:

    docker events --filter event=create --filter event=destroy | tee events.log -> Option A
  4. Quick Check:

    Use tee to save and view events simultaneously [OK]
Quick Trick: Use tee to save and view docker events output [OK]
Common Mistakes:
  • Using invalid combined event filter
  • Expecting --output flag to save file
  • Using > loses live output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes