nerdexam
Cisco

200-901 · Question #542

A developer prepared the Dockerfile and already built a web application container with the image name: 搈yWebApp? Requests made to the server public IP address on port 8080 must be redirected to port…

The correct answer is A. docker run -t -i myWebApp -p 8080:80 bash. The docker run command with interactive flags, correct host-to-container port mapping, the image name, and a shell entry point starts an interactive container session with the required port forwarding.

Application Deployment and Security

Question

A developer prepared the Dockerfile and already built a web application container with the image name: 搈yWebApp? Requests made to the server public IP address on port 8080 must be redirected to port 80 on the container. The developer wants to start the container and access the Bash shell while the application serves the requests. Which command is used? A. B. C. D.

Options

  • Adocker run -t -i myWebApp -p 8080:80 bash
  • Bdocker cmd -t -i myWebApp -d 80:808 bash
  • Cdocker start -t -i apache2 -p 8080:80 bash
  • Ddocker exec -t -i apache2 -bash

How the community answered

(34 responses)
  • A
    74% (25)
  • B
    9% (3)
  • C
    3% (1)
  • D
    15% (5)

Why each option

The docker run command with interactive flags, correct host-to-container port mapping, the image name, and a shell entry point starts an interactive container session with the required port forwarding.

Adocker run -t -i myWebApp -p 8080:80 bashCorrect

docker run creates and starts a new container from the myWebApp image; -t allocates a pseudo-TTY and -i keeps STDIN open for interactive shell access. The flag -p 8080:80 maps host port 8080 to container port 80 exactly as required, and specifying bash as the entry point opens the Bash shell while the application continues to serve requests.

Bdocker cmd -t -i myWebApp -d 80:808 bash

docker cmd is not a valid Docker CLI command, and the port mapping -d 80:808 reverses the required host-to-container port direction and uses the wrong port numbers.

Cdocker start -t -i apache2 -p 8080:80 bash

docker start is used to restart an already stopped container rather than create a new one, and apache2 is not the specified image name - myWebApp is.

Ddocker exec -t -i apache2 -bash

docker exec runs a command inside an already-running container and cannot start a new container, and apache2 is not the correct image name.

Concept tested: Docker run command with port mapping and interactive shell

Source: https://docs.docker.com/engine/reference/commandline/run/

Topics

#Docker#Containerization#Port Mapping#CLI

Community Discussion

No community discussion yet for this question.

Full 200-901 Practice