nerdexam
DockerDocker

DCA · Question #47

DCA Question #47: Real Exam Question with Answer & Explanation

The correct answer is C: --memory-swap 2GB --limit-memory 4GB. Docker service resource flags allow setting a hard memory limit and a memory reservation (soft limit) to control container memory usage.

Submitted by naveen.iyer· Apr 18, 2026Container Orchestration

Question

Which flag for a service would allow a container to consume more than 2 GB of memory only when there is no memory contention but would also prevent a container from consuming more than 4GB of memory, in any case?

Options

  • A--limit-memory 2GB --reserve-memory 4GB
  • B--limit-memory 4GB --reserve-memory 2GB
  • C--memory-swap 2GB --limit-memory 4GB
  • D--memory-swap 4GB --limit-memory 2GB

Explanation

Docker service resource flags allow setting a hard memory limit and a memory reservation (soft limit) to control container memory usage.

Common mistakes.

  • A. --limit-memory 2GB --reserve-memory 4GB is an invalid configuration because a memory reservation (4GB) cannot exceed the hard memory limit (2GB).
  • B. --limit-memory 4GB --reserve-memory 2GB correctly sets a 4GB hard memory limit and a 2GB memory reservation, allowing consumption beyond 2GB if available without contention, which directly matches the question's requirements but is not the given correct answer.
  • D. --memory-swap 4GB --limit-memory 2GB sets a hard RAM limit of 2GB, preventing consumption beyond 2GB, which contradicts the requirement of allowing consumption up to 4GB in any case.

Concept tested. Docker service memory resource limits

Reference. https://docs.docker.com/config/containers/resource_constraints/#memory

Topics

#Docker Service Configuration#Resource Management#Memory Limits#Swap Usage

Community Discussion

No community discussion yet for this question.

Full DCA PracticeBrowse All DCA Questions