CKAD Application Design and Build Practice Question
You have a multi-stage Docker build. The first stage compiles a binary, and the second stage copies the binary from the first stage. What is the correct COPY syntax to copy a file named 'app' from the first stage named 'builder'?
⚠ Common exam trap
Many exam-takers confuse the `--from` flag with other Docker flags like `--stage` or `source=`, or mistakenly think a simple COPY from the build context will work, failing to recognize that multi-stage builds require explicit stage referencing to access files from previous stages.
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/
The `--from=builder` flag in the COPY instruction allows you to copy files from a specific build stage (named 'builder') in a multi-stage Docker build. This syntax is essential for multi-stage builds, where the first stage compiles artifacts and the second stage copies only the necessary binaries, reducing final image size.
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 app /app/
Why it's wrong here
A plain COPY without any stage reference copies files from the build context, which is the local directory sent to the Docker daemon. In a multi-stage build, the compiled binary from the first stage lives in that stage's filesystem, not necessarily in the context. Therefore, this command either fails because the file isn't in the context or copies the wrong (source) version.
- ✓
COPY --from=builder app /app/
Why this is correct
Using COPY --from=builder explicitly tells Docker to look in the builder stage's filesystem for the app directory and copy it into the current stage's /app. This flag is essential in multi-stage builds to transfer only the compiled artifact while leaving build tools behind. It precisely identifies the source stage by name, making the build reproducible and clear.
- ✗
COPY --stage=builder app /app/
Why it's wrong here
In Docker multi-stage builds, the COPY command does not support a --stage flag; using it when referencing a previous stage causes a parser error and the build stops. The correct way to select a source stage is the --from flag. For instance, COPY --from=builder app /app/ pulls app from the stage named builder.
- ✗
COPY source=builder app /app/
Why it's wrong here
This option resembles the --from syntax but incorrectly treats the source as a key-value pair (source=builder). Dockerfile COPY expects the stage indicator as a flag, not as an assignment. Valid syntax is COPY --from=builder app /app/, where --from is a separate token and builder is its value. Any other form is malformed and will fail validation.
Go deeper
Related to this question
About these practice questions
Courseiva writes every CKAD question from scratch — 826 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
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.