Recall & Review
beginner
What are CPU shares in Docker?
CPU shares define the relative priority or weight for CPU allocation among containers when the host CPU is contended. Default value is 1024; higher shares get more CPU proportionally.
Click to reveal answer
beginner
What does setting a CPU limit do for a Docker container?
A CPU limit sets the maximum CPU resources a container can use (e.g., via --cpus). It prevents the container from using more than the limit, protecting other containers and the host.
Click to reveal answer
intermediate
How do you specify CPU shares using the Docker run command?
Use the option --cpu-shares followed by a number (default 1024), for example: docker run --cpu-shares=512 myimage gives half the priority of default.
Click to reveal answer
intermediate
Explain the difference between CPU shares and CPU quota in Docker.
CPU shares set relative priority for CPU time among containers when CPU is contended (no hard limit). CPU quota (with --cpu-quota and --cpu-period) sets an absolute limit on CPU usage time.
Click to reveal answer
beginner
What happens if a container tries to use more CPU than its limit?
Docker will throttle the container's CPU usage using CFS quota, ensuring it does not exceed the set limit and protecting other containers and the host system.
Click to reveal answer
Which Docker option sets the relative CPU priority for a container?
✗ Incorrect
The --cpu-shares option sets relative priority (weight) for CPU allocation when contended.
What does the Docker --cpu-quota option control?
✗ Incorrect
--cpu-quota (with --cpu-period) limits the maximum CPU time a container can consume in a period.
If no CPU limits are set, what happens when multiple containers compete for CPU?
✗ Incorrect
By default, containers share CPU based on --cpu-shares (1024); higher shares get proportionally more when contended.
How do you limit a container to use at most 2 CPUs using Docker run?
✗ Incorrect
The --cpus=2 option limits the container to at most 2 CPUs (equivalent to quota/period settings).
What is the effect of setting CPU shares to 1024 for a container?
✗ Incorrect
1024 is the default --cpu-shares value, defining relative priority, not absolute limits or guarantees.
Describe how CPU limits and shares work in Docker and why they are important.
Think about sharing a pizza: shares decide portions when fighting over slices, limits prevent taking the whole pie.
You got /4 concepts.
Explain the difference between CPU shares, CPU quota, and --cpus in Docker.
Shares are like voting weight, quota is a timer, --cpus is a simple cap on cores.
You got /3 concepts.