Courseiva

CKAD Application Design and Build Practice Question

A multi-stage build has two stages named 'builder' and 'final'. Which instruction copies artifacts from the builder stage to the final stage?

⚠ Common exam trap

Candidates often confuse the COPY --from syntax with the ADD instruction or forget the --from flag entirely, assuming COPY alone can reference a stage name, which leads to a build error or unintended host path copy.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

COPY --from=builder /app /app

In a multi-stage Docker build, the COPY instruction with the --from flag allows you to copy files from a named previous stage (here 'builder') into the current stage ('final'). This is the correct syntax to selectively transfer build artifacts without carrying over intermediate layers or dependencies.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    COPY --from=builder /app /app

    Why this is correct

    This is the correct syntax for copying artifacts from a previous stage in a multi-stage Docker build. The `--from=builder` flag specifies the named stage called `builder`, and both `/app` arguments are container filesystem paths: the source path inside the builder stage's filesystem and the destination path in the current build stage. Because the `COPY` instruction requires this exact format to reference another stage, this command successfully copies the application from the builder stage into the final image.

  • ✗

    FROM builder /app /app

    Why it's wrong here

    The `FROM` instruction is solely used to define a base image or a named stage at the beginning of a build stage—it cannot accept file paths or perform any copying. Writing `FROM builder /app /app` is syntactically invalid because `FROM` expects only an image name (and optionally `AS <alias>`), and passing paths will cause the builder to treat `/app /app` as part of the image reference, resulting in an error. To copy files from a previous stage, you must use `COPY --from=<stage>`, not `FROM`.

  • ✗

    COPY builder /app /app

    Why it's wrong here

    This `COPY` command is missing the mandatory `--from` flag, so Docker interprets the first argument `builder` as a path in the current build context, not as a reference to a previous build stage. Since there is likely no directory or file named `builder` in the build context, the build will fail with a 'file not found' error, or worse, copy unintended content if such a path exists. The correct form must include `--from=builder` to tell `COPY` that the source originates from another stage's filesystem.

  • ✗

    ADD --from=builder /app /app

    Why it's wrong here

    The `ADD` instruction does not support the `--from` flag; that flag is exclusive to `COPY` in the context of multi-stage builds. Even though `ADD` can copy files from the build context or remote URLs, it lacks the capability to reference another build stage, so this command is syntactically invalid and will be rejected by Docker. For copying between stages, you must use `COPY --from=<stage>`, and use `ADD` only for its specialized behaviors like automatic tar extraction or remote file fetching.

About these practice questions

One of 826 original CKAD practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This CKAD practice question is part of Courseiva's free CNCF certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the CKAD exam.