0
0
Dockerdevops~20 mins

Memory limits and reservations in Docker - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Memory Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Understanding Docker Memory Limit Output
What is the output of the following Docker command when inspecting a container's memory limits?
Docker
docker inspect --format='{{.HostConfig.Memory}}' my_container
A1073741824
B0
C536870912
DMemory limit not set
Attempts:
2 left
💡 Hint
If no memory limit is set, Docker returns 0 for the Memory field.
🧠 Conceptual
intermediate
2:00remaining
Difference Between Memory Limit and Memory Reservation
Which statement correctly describes the difference between Docker's memory limit and memory reservation?
AMemory limit is a hard cap; memory reservation is a soft guarantee.
BMemory limit applies only to CPU, memory reservation applies only to disk.
CBoth memory limit and reservation are hard caps on memory usage.
DMemory reservation is a hard cap; memory limit is a soft guarantee.
Attempts:
2 left
💡 Hint
Think about which setting restricts usage strictly and which one reserves resources.
Configuration
advanced
2:30remaining
Correct Docker Compose Memory Settings
Which Docker Compose service configuration correctly sets a memory limit of 512MB and a memory reservation of 256MB?
Docker
services:
  app:
    image: myapp
    deploy:
      resources:
        limits:
          memory: 512M
        reservations:
          memory: 256M
A
services:
  app:
    image: myapp
    deploy:
      resources:
        limits:
          memory: 512mb
        reservations:
          memory: 256mb
B
services:
  app:
    image: myapp
    deploy:
      resources:
        limits:
          memory: 512MB
        reservations:
          memory: 256MB
C
services:
  app:
    image: myapp
    deploy:
      resources:
        limits:
          memory: 512
        reservations:
          memory: 256
D
services:
  app:
    image: myapp
    deploy:
      resources:
        limits:
          memory: 512M
        reservations:
          memory: 256M
Attempts:
2 left
💡 Hint
Memory values in Docker Compose use uppercase 'M' for megabytes without 'B'.
Troubleshoot
advanced
2:30remaining
Diagnosing Memory Limit Enforcement Failure
A container is set with a memory limit of 256MB but uses more memory without being killed. What is the most likely cause?
AThe container is running with the --memory-swap flag set to unlimited.
BThe container was started without the --memory flag.
CThe host machine has swap disabled.
DThe container is using the memory reservation setting instead of limit.
Attempts:
2 left
💡 Hint
Check if swap settings affect memory limit enforcement.
🔀 Workflow
expert
3:00remaining
Order of Steps to Set Memory Limits on a Running Container
What is the correct order of steps to apply a memory limit of 1GB to an already running Docker container named 'webapp'?
A1,4,2,3
B2,1,3,4
C1,2,3,4
D4,1,2,3
Attempts:
2 left
💡 Hint
You cannot change memory limits on a running container without restarting it.