200-901 Application Deployment and Security Practice Question
A Docker container running a web application needs to be accessible on the host's port 8080. The application inside the container listens on port 80. Which docker run command achieves this?
⚠ Common exam trap
200-901 often tests the order of the -p flag — candidates reverse host and container ports or confuse -p with -P and --expose, leading to a mapping that does not match the application's listening port.
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 myapp
The -p flag maps a host port to a container port using the format host:container. Since the host should listen on 8080 and the application inside the container listens on 80, the correct mapping is -p 8080:80. The -d flag runs the container detached, which is appropriate for a web service.
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 -d --expose 80 -p 8080 myapp
Why it's wrong here
--expose only documents port 80 inside the container; it publishes nothing to the host, and -p 8080 supplies no container port, so no mapping occurs. --expose is tempting for declaring listening ports, but it never creates host accessibility.
- ✗
docker run -d -p 80:8080 myapp
Why it's wrong here
-p 80:8080 maps host port 80 to container port 8080, the reverse of what is required, so the app on container port 80 stays unreachable. It is tempting because both ports appear, but the host:container order is inverted.
- ✗
docker run -d -P 8080:80 myapp
Why it's wrong here
-P publishes all exposed ports to randomly assigned host ports; the 8080:80 argument is invalid with it, so host port 8080 is never bound. -P is tempting for automatic publishing, but it cannot target a specific host port.
- ✓
docker run -d -p 8080:80 myapp
Why this is correct
Publishing with `-p 8080:80` maps host port 8080 to container port 80, satisfying the requirement that external traffic on 8080 reaches the application listening internally on 80. The `-d` flag runs the container detached, so the terminal returns immediately while the web app keeps serving.
Go deeper
Related to this question
About these practice questions
One of 975 original 200-901 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 and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Cisco exam blueprint
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.