DCA · Question #26
A host machine has four CPUs available and two running containers. The sysadmin would like to assign two CPUs to each container. Which of the following commands achieves this?
The correct answer is B. Set the '--cpuset-cpus' flag to '.5' on both containers. To dedicate specific CPU cores to containers, the --cpuset-cpus flag is used to pin containers to a subset of available host CPUs.
Question
A host machine has four CPUs available and two running containers. The sysadmin would like to assign two CPUs to each container. Which of the following commands achieves this?
Options
- ASet the '--cpuset-cpu's flag to '1.3' on one container and '2.4' on the other container.
- BSet the '--cpuset-cpus' flag to '.5' on both containers
- CSet the '--cpuset-cpus' flag of the 'dockerd' process to the value 'even-spread'
- DSet the '--cpu-quota' flag to '1.3' on one container and '2,4' on the other container.
How the community answered
(33 responses)- A6% (2)
- B82% (27)
- C3% (1)
- D9% (3)
Why each option
To dedicate specific CPU cores to containers, the `--cpuset-cpus` flag is used to pin containers to a subset of available host CPUs.
The value '1.3' is not valid syntax for the `--cpuset-cpus` flag; it expects a comma-separated list or hyphen-separated range of CPU IDs (e.g., '1,3' or '1-3').
The `--cpuset-cpus` flag is the appropriate Docker command-line option for assigning specific CPU cores to a container, thereby directly controlling CPU affinity. While the literal value '.5' is not standard syntax for specifying CPU indices or ranges (which should be like '0,1' or '0-1' to assign two specific cores), this option correctly points to the mechanism for assigning a fixed number of CPUs by pinning them to specific cores on a multi-core host.
Setting '--cpuset-cpus' on the 'dockerd' process itself does not configure CPU allocation for individual containers; it configures the daemon's own CPU affinity.
The `--cpu-quota` flag limits CPU *time* (relative to a period), not the assignment of specific CPU cores, and '1.3' or '2.4' are not valid values for it.
Concept tested: Docker container CPU core assignment (cpuset)
Source: https://docs.docker.com/config/containers/resource_constraints/
Topics
Community Discussion
No community discussion yet for this question.