Bird
0
0

You want to configure Docker daemon to use the journald logging driver by default and limit log file size to 5 MB with 2 rotated files. Which daemon.json configuration is correct?

hard📝 Best Practice Q15 of 15
Docker - Logging and Monitoring
You want to configure Docker daemon to use the journald logging driver by default and limit log file size to 5 MB with 2 rotated files. Which daemon.json configuration is correct?
A{ "log-driver": "journald", "log-opts": { "max-size": "5m", "max-file": "2" } }
B{ "logging-driver": "journald", "logging-opts": { "max-size": "5m", "max-file": "2" } }
C{ "log-driver": "journald", "log-opts": { "max-size": 5, "max-file": 2 } }
D{ "log-driver": "journald", "log-opts": { "max-size": "5MB", "max-file": "2" } }
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct keys in daemon.json

    The keys are "log-driver" and "log-opts" (not "logging-driver" or "logging-opts").
  2. Step 2: Check value formats for options

    max-size must be a string with units like "5m" (not number or "5MB" which is invalid).
  3. Final Answer:

    { "log-driver": "journald", "log-opts": { "max-size": "5m", "max-file": "2" } } -> Option A
  4. Quick Check:

    Use "log-driver" and string values with units [OK]
Quick Trick: Use "log-driver" and string sizes like "5m" in daemon.json [OK]
Common Mistakes:
  • Using wrong keys like logging-driver
  • Using numeric values without units
  • Using invalid units like MB instead of m

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes