nerdexam
Docker

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.

Submitted by emma.c· Apr 18, 2026Installation and Configuration

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)
  • A
    6% (2)
  • B
    82% (27)
  • C
    3% (1)
  • D
    9% (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.

ASet the '--cpuset-cpu's flag to '1.3' on one container and '2.4' on the other container.

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').

BSet the '--cpuset-cpus' flag to '.5' on both containersCorrect

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.

CSet the '--cpuset-cpus' flag of the 'dockerd' process to the value 'even-spread'

Setting '--cpuset-cpus' on the 'dockerd' process itself does not configure CPU allocation for individual containers; it configures the daemon's own CPU affinity.

DSet the '--cpu-quota' flag to '1.3' on one container and '2,4' on the other container.

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

#Docker resource limits#CPU allocation#Container configuration#Control Groups (cgroups)

Community Discussion

No community discussion yet for this question.

Full DCA Practice