Bird
0
0

You want to run a container that should always have at least 1GB of memory available but never use more than 2GB. Which Docker run options correctly enforce this?

hard📝 Best Practice Q15 of 15
Docker - Resource Management
You want to run a container that should always have at least 1GB of memory available but never use more than 2GB. Which Docker run options correctly enforce this?
Adocker run --memory=1g --memory-reservation=2g mycontainer
Bdocker run --memory-reservation=1g --memory=2g mycontainer
Cdocker run --memory=2g --memory-reservation=1g mycontainer
Ddocker run --memory-reservation=2g --memory=1g mycontainer
Step-by-Step Solution
Solution:
  1. Step 1: Identify memory reservation and limit roles

    Memory reservation sets soft minimum (1GB), memory limit sets hard max (2GB).
  2. Step 2: Match options to roles

    docker run --memory=2g --memory-reservation=1g mycontainer correctly sets --memory=2g (max) and --memory-reservation=1g (min).
  3. Final Answer:

    docker run --memory=2g --memory-reservation=1g mycontainer -> Option C
  4. Quick Check:

    Limit=2g, Reservation=1g for min and max [OK]
Quick Trick: Memory limit is max, reservation is min; order matters [OK]
Common Mistakes:
  • Swapping limit and reservation values
  • Setting reservation higher than limit
  • Confusing units or flags

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes