XK0-006 Automation, Orchestration, and Scripting Practice Question
A DevOps engineer needs to run a Docker container in the background with port mapping from host port 8080 to container port 80, and name the container 'webapp'. Which command accomplishes this?
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 -d -p 8080:80 --name webapp nginx
The docker run command with -d (detach), -p (port mapping), and --name options is the correct way to run a container in the background with port mapping and a name.
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 start -d -p 8080:80 --name webapp nginx
Why it's wrong here
docker start starts an existing stopped container, does not accept -p or --name to configure new mappings.
- ✗
docker create -d -p 8080:80 --name webapp nginx
Why it's wrong here
docker create creates a container but does not start it; -d is irrelevant for create.
- ✓
docker run -d -p 8080:80 --name webapp nginx
Why this is correct
Correct. -d runs detached, -p maps ports, --name assigns a name.
- ✗
docker compose up -d -p 8080:80 --name webapp nginx
Why it's wrong here
docker compose up is for multi-container applications defined in a compose file, not for a single container with direct port mapping.
Go deeper
Related to this question
About these practice questions
One of 979 original XK0-006 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This XK0-006 practice question is part of Courseiva's free CompTIA 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 XK0-006 exam.