nerdexam
Cisco

350-901 · Question #84

Refer to the exhibit. The command docker build --tag=friendlyhello . is run to build a docker image from the given Dockerfile, requirements.txt, and app.py. Then the command docker run -p 4000:80…

The correct answer is A. http://localhost:4000. The docker run -p 4000:80 command maps port 4000 on the host machine to port 80 inside the Docker container, making the container's service accessible from the host's localhost on port 4000.

Application Deployment and Security

Question

Refer to the exhibit. The command docker build --tag=friendlyhello . is run to build a docker image from the given Dockerfile, requirements.txt, and app.py. Then the command docker run -p 4000:80 friendlyhello is executed to run the application. Which URL is entered in the web browser to see the content served by the application?

Exhibit

350-901 question #84 exhibit

Options

How the community answered

(36 responses)
  • A
    72% (26)
  • B
    14% (5)
  • C
    6% (2)
  • D
    8% (3)

Why each option

The `docker run -p 4000:80` command maps port 4000 on the host machine to port 80 inside the Docker container, making the container's service accessible from the host's localhost on port 4000.

Ahttp://localhost:4000Correct

The `-p 4000:80` flag in the `docker run` command publishes port 80 from the container to port 4000 on the host machine. This means that to access the application running inside the container (which is listening on port 80), you must connect to the host's IP address (localhost) using the mapped external port, which is 4000.

Bhttp://localhost:80

Port 80 on `localhost` is not mapped to the container's application unless explicitly configured otherwise, and usually host port 80 would require root privileges.

Chttp://127.0.0.1:80

`127.0.0.1` is the loopback address for `localhost`, but port 80 refers to the container's internal port, which is not directly accessible from the host without port mapping.

Dhttp://0.0.0.0:80

`0.0.0.0` is a wildcard address used within the container to listen on all available network interfaces, but it is not a URL to be entered in a web browser from the host.

Concept tested: Docker port mapping and application access

Source: https://docs.docker.com/engine/reference/commandline/run/#publish-or-expose-port--p---expose

Topics

#Docker#Containerization#Port Mapping#Application Access

Community Discussion

No community discussion yet for this question.

Full 350-901 Practice