CKAD Application Design and Build Practice Question
Which TWO options are valid ways to tag an image when building with Docker?
⚠ Common exam trap
Many candidates confuse `docker tag` with `docker commit` or `docker build` flags, mistakenly thinking `--name` or `docker run` can assign tags, when only `docker tag` and `docker build -t` are valid for tagging images.
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 tag myapp:1.0 myrepo/myapp:1.0
The `docker tag` command explicitly creates a new tag referencing an existing image, allowing you to assign a new name and tag (e.g., `myrepo/myapp:1.0`) to an already built image (e.g., `myapp:1.0`). This is a standard way to prepare an image for pushing to a registry without rebuilding.
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 build --name myapp:1.0 .
Why it's wrong here
docker build has no --name flag; the Docker CLI strictly parses flags, so --name is an unrecognized option that causes the build to fail before any image is produced. The correct way to assign a tag during a build is -t or --tag, followed by the repository:tag reference, as in docker build -t myapp:1.0 .
- ✗
docker commit myapp:1.0 myrepo/myapp:1.0
Why it's wrong here
docker commit takes a container ID or container name as its source argument, not an image reference. Here, myapp:1.0 refers to an existing image, implying you are trying to tag that image, but commit instead creates a new image by saving a container's writable layer. To tag an existing image, you must use docker tag, which simply creates an alias to the same image ID.
- ✓
docker tag myapp:1.0 myrepo/myapp:1.0
Why this is correct
docker tag is the direct command for assigning an additional tag to an existing image. It creates a new mutable alias (myrepo/myapp:1.0) that points to the same underlying image ID as the source image (myapp:1.0), without modifying the image's filesystem or layers. This is the standard mechanism for preparing a local image to be pushed to a different repository or registry.
- ✗
docker run -t myapp:1.0 myrepo/myapp:1.0
Why it's wrong here
docker run is used to create and start a container from an image; it has no capability to tag images. The -t flag allocates a pseudo-TTY for the container's stdin, not a tag name, and the trailing myrepo/myapp:1.0 is interpreted as the command to execute inside the container—not a tag to assign. Since no executable named myrepo/myapp:1.0 exists in the container, this command would fail at runtime, and no image tagging would occur.
- ✓
docker build -t myapp:1.0 .
Why this is correct
The -t (--tag) flag on docker build assigns a repository and tag to the newly created image directly during the build process. The first argument after the flag is the tag reference (myapp:1.0), and the final . specifies the build context (the directory containing the Dockerfile). This is the canonical, built-in way to ensure the resulting image is immediately identified with a tag, and it also allows multiple -t flags to apply several tags at once.
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.