Courseiva

200-901 Application Deployment and Security Practice Question

In Docker, which command is used to build an image from a Dockerfile and tag it as 'myapp:v1'?

⚠ Common exam trap

Cisco often tests the distinction between `docker build` (for creating images from a Dockerfile) and `docker run` (for starting containers), and the trap here is that candidates confuse the `-t` flag in `docker run` (which allocates a TTY) with the `-t` flag in `docker build` (which tags the image).

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 -t myapp:v1 .` command builds a Docker image from the Dockerfile in the current directory and tags it with the name `myapp` and version tag `v1`. The `-t` flag assigns the tag, and the dot (`.`) specifies the build context (the current directory). This is the standard Docker command for building and tagging images.

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 run -t myapp:v1 .

    Why it's wrong here

    docker run starts a container from an image, so 'myapp:v1' is parsed as an image to launch, not a tag to create; no Dockerfile is read. It is tempting because it is the most-used Docker command, but it suits executing a container, not building an image.

  • ✓

    docker build -t myapp:v1 .

    Why this is correct

    The -t flag assigns the repository name and tag myapp:v1 to the built image, while the trailing dot supplies the build context (current directory) containing the Dockerfile. Without -t the image would be untagged, so this satisfies the tagging requirement precisely.

  • ✗

    docker create myapp:v1 .

    Why it's wrong here

    docker create instantiates a container from an existing image and accepts no Dockerfile; the argument 'myapp:v1' would be treated as an image reference, not a tag to assign. It is tempting as a container-creation verb, but it suits preparing a stopped container, not building an image.

  • ✗

    docker commit myapp:v1 .

    Why it's wrong here

    docker commit snapshots a running container's filesystem into an image; it never reads a Dockerfile, so no build steps execute and no tag is applied. It is tempting because it does produce an image, but that suits capturing manual in-container changes, not reproducible Dockerfile builds.

About these practice questions

This 200-901 question is part of Courseiva's 975-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam 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 200-901 practice question is part of Courseiva's free Cisco 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 200-901 exam.