200-901 · Question #535
Refer to the exhibit. An engineer is creating a Dockerfile for an application to run on a container. Application is a web application build on the Python Flask framework. Which port of the…
The correct answer is C. EXPOSE 80. In a Dockerfile, the EXPOSE instruction declares which ports a container expects to listen on, indicating its intended network reachability from outside.
Question
Refer to the exhibit. An engineer is creating a Dockerfile for an application to run on a container. Application is a web application build on the Python Flask framework. Which port of the Dockerfile provides desired reachability to the application from the outside of the container?
Exhibit
Options
- ARUN pip3 install Flask
- BMAINTAINER User One ([email protected])
- CEXPOSE 80
- DCOPY ./app
How the community answered
(52 responses)- A4% (2)
- B2% (1)
- C94% (49)
Why each option
In a Dockerfile, the `EXPOSE` instruction declares which ports a container expects to listen on, indicating its intended network reachability from outside.
`RUN pip3 install Flask` executes a command during the image build process to install Python dependencies, which is not related to network port exposure.
`MAINTAINER User One ([email protected])` is a deprecated instruction used for setting metadata about the image author, unrelated to network ports.
The `EXPOSE` instruction in a Dockerfile serves to document which ports a container will listen on at runtime, making it discoverable for inter-container communication or for publishing to the host. While it doesn't automatically publish the port, it's the declaration of intended network reachability.
`COPY ./app` copies application source code from the build context into the Docker image, which is a file system operation and has no direct bearing on network port reachability.
Concept tested: Dockerfile EXPOSE instruction
Source: https://docs.docker.com/reference/dockerfile/#expose
Topics
Community Discussion
No community discussion yet for this question.
