Courseiva
mediumMultiple Choice

200-901 Practice Question: A developer needs to run a temporary container…

A developer needs to run a temporary container that executes a command and then exits. Which Docker command should be used?

⚠ Common exam trap

Cisco often tests the distinction between `docker run` (creates and starts a new container) and `docker exec` (attaches to an existing running container), leading candidates to mistakenly choose `docker exec` for running a one-time command.

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 run --rm

The `docker run --rm` command creates a container, runs the specified command, and automatically removes the container filesystem after it exits. This is the correct approach for a temporary, disposable container that should not persist after execution. The `--rm` flag ensures cleanup without manual intervention.

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 exec

    Why it's wrong here

    docker exec attaches a command to an already-running container; it cannot create one, so nothing exists to execute against. It is the right tool for inspecting or debugging a live container, such as opening a shell inside a running service.

  • ✗

    docker run -d

    Why it's wrong here

    `docker run -d` starts the container detached, returning the container ID immediately without attaching to its output, so the command's exit status and logs are not surfaced to the developer. Detached mode suits long-running services such as web servers or databases, where the container persists in the background rather than executing a one-off task and terminating.

  • ✗

    docker start

    Why it's wrong here

    docker start restarts an existing stopped container; it cannot create a new one from an image, so no temporary container is produced. It is correct when resuming a previously created container that already holds the required configuration and state.

  • ✓

    docker run --rm

    Why this is correct

    `docker run --rm` starts a container, executes its command, then automatically deletes the container once it exits, satisfying the temporary requirement. Without `--rm`, the stopped container persists and consumes disk space, requiring manual `docker rm` cleanup.

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.