Bird
0
0

You want to monitor CPU and memory usage of a specific container named webapp and save the output once to a file. Which command should you use?

hard📝 Best Practice Q15 of 15
Docker - Resource Management
You want to monitor CPU and memory usage of a specific container named webapp and save the output once to a file. Which command should you use?
Adocker stats --stream=false webapp > usage.txt
Bdocker stats webapp --output usage.txt
Cdocker monitor webapp > usage.txt
Ddocker stats --no-stream --format 'table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}' webapp > usage.txt
Step-by-Step Solution
Solution:
  1. Step 1: Choose the correct command and options

    To get a one-time snapshot, use --no-stream. To format output with container name, CPU, and memory, use --format with a table layout.
  2. Step 2: Redirect output to a file

    Use shell redirection > usage.txt to save the output to a file named usage.txt.
  3. Final Answer:

    docker stats --no-stream --format 'table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}' webapp > usage.txt -> Option D
  4. Quick Check:

    One-time formatted output saved to file = docker stats --no-stream --format 'table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}' webapp > usage.txt [OK]
Quick Trick: Use --no-stream and --format, redirect output to file [OK]
Common Mistakes:
  • Using invalid docker monitor command
  • Assuming --output option exists
  • Using --stream=false instead of --no-stream

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes