Courseiva

CKAD Application Design and Build Practice Question

Which command builds a Docker image from the current directory and tags it as 'myapp:v1'?

⚠ Common exam trap

Test-takers frequently confuse the `docker build` syntax with `docker tag` or misplace the tag argument, thinking it can be passed as a positional parameter instead of using the `-t` flag.

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

✓

docker build -t myapp:v1 .

The `docker build` command with the `-t` flag (short for `--tag`) is the standard way to build an image from a Dockerfile in the current directory (`.`) and assign it a tag `myapp:v1`. The `-t` flag specifies the repository and tag in the format `name:tag`, and the `.` indicates the build context (the current directory).

Answer analysis

Option-by-option breakdown

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

  • ✗

    docker image build --name myapp:v1 .

    Why it's wrong here

    The `docker image build` subcommand is a valid alias for `docker build`, but the `--name` flag is not a recognized parameter for the build command; naming an image is done with `--tag` or `-t`. Additionally, the positional argument `.` specifies the build context, which is correct, but without a valid tag flag the command would fail because `--name` is interpreted as an unknown flag.

  • ✓

    docker build -t myapp:v1 .

    Why this is correct

    The `docker build -t myapp:v1 .` command is the correct syntax. The `-t` (or `--tag`) flag assigns the name and tag `myapp:v1` to the built image, while the `.` specifies the current directory as the build context, containing the Dockerfile and any files needed for the build. This command reads the Dockerfile from the context, builds the image, and tags it accordingly.

  • ✗

    docker build myapp:v1 .

    Why it's wrong here

    The `docker build myapp:v1 .` command is missing the `-t` flag. In Docker's build command, the first positional argument is always the build context path, not the image name. Here, `myapp:v1` would be interpreted as the context, and the `.` becomes a second positional argument, leading to an error or an attempt to use a non-existent directory as the build context.

  • ✗

    docker tag myapp:v1 .

    Why it's wrong here

    The `docker tag myapp:v1 .` command is intended for tagging an existing image, not for building one. It requires a source image reference (e.g., `myapp:latest`) and a new tag (e.g., `myapp:v1`) as arguments, but the `.` is not a valid image reference and does not serve as a build context either. This command would fail because there is no image named `.` and no build process is triggered.

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 →

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.