0
0
Dockerdevops

Memory limits and reservations in Docker - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a memory limit in Docker?
A memory limit sets the maximum amount of memory a container can use. If the container tries to use more, it may be stopped or killed.
Click to reveal answer
beginner
What does memory reservation mean in Docker?
Memory reservation is the amount of memory that Docker guarantees to a container. It helps ensure the container has enough memory to run smoothly.
Click to reveal answer
beginner
How do you set a memory limit when running a Docker container?
Use the option --memory followed by the limit size, for example: docker run --memory=500m myimage limits memory to 500 megabytes.
Click to reveal answer
intermediate
What happens if a container exceeds its memory limit?
Docker may stop or kill the container to prevent it from using more memory than allowed, protecting the host system.
Click to reveal answer
intermediate
Why use memory reservation along with memory limits?
Memory reservation ensures the container has enough memory to run well, while the limit prevents it from using too much and affecting other containers.
Click to reveal answer
Which Docker option sets the maximum memory a container can use?
A--cpu-shares
B--memory
C--memory-reservation
D--memory-swap
What does --memory-reservation do in Docker?
AGuarantees a minimum memory amount
BSets the maximum memory limit
CLimits CPU usage
DSets disk space limit
If a container exceeds its memory limit, what usually happens?
AIt gets more memory automatically
BIt slows down but keeps running
CDocker stops or kills the container
DNothing happens
Which is true about memory reservation?
AIt is the minimum memory guaranteed
BIt sets disk quota
CIt controls CPU priority
DIt is the maximum memory allowed
How do you limit a container's memory to 1 gigabyte?
Adocker run --memory-reservation=1g ...
Bdocker run --memory-swap=1g ...
Cdocker run --cpu-shares=1g ...
Ddocker run --memory=1g ...
Explain the difference between memory limits and memory reservations in Docker.
Think about max vs guaranteed memory.
You got /4 concepts.
    Describe how to set memory limits and reservations when running a Docker container.
    Recall the Docker run command options.
    You got /4 concepts.