nerdexam
Docker

DCA · Question #33

What is the purpose of multi-stage builds?

The correct answer is B. Optimizing images by copying artifacts selectively from previous stages. Multi-stage builds are primarily used to optimize Docker images by reducing their size and attack surface.

Submitted by the_admin· Apr 18, 2026Image Creation, Management, and Registry

Question

What is the purpose of multi-stage builds?

Options

  • ABetter logical separation of Dockerfile instructions for better readability
  • BOptimizing images by copying artifacts selectively from previous stages
  • CBetter caching when building Docker images
  • DFaster image builds by allowing parallel execution of Docker builds

How the community answered

(33 responses)
  • A
    6% (2)
  • B
    91% (30)
  • D
    3% (1)

Why each option

Multi-stage builds are primarily used to optimize Docker images by reducing their size and attack surface.

ABetter logical separation of Dockerfile instructions for better readability

While multi-stage builds can improve the logical organization of a Dockerfile, their main purpose is not just readability but concrete image optimization.

BOptimizing images by copying artifacts selectively from previous stagesCorrect

Multi-stage builds optimize images by allowing the separation of build-time dependencies from runtime dependencies. Only the necessary artifacts, such as compiled binaries, are copied from an earlier build stage to the final production image, discarding build tools and intermediate files and significantly reducing the final image size.

CBetter caching when building Docker images

Although caching is leveraged during multi-stage builds, it's a general Docker build feature; the primary purpose of multi-stage builds is not better caching, but image size reduction through artifact selection.

DFaster image builds by allowing parallel execution of Docker builds

Multi-stage builds execute stages sequentially; they do not inherently allow for parallel execution of Docker builds, which would typically require separate build processes.

Concept tested: Docker multi-stage builds for image optimization

Source: https://docs.docker.com/build/building/multi-stage/

Topics

#Multi-stage builds#Dockerfile#Image optimization#Image size

Community Discussion

No community discussion yet for this question.

Full DCA Practice