300-910 · Question #22
A DevOps engineer has built a new container and must open port 8080 for intercontainer communication. Which command must be added in a Dockerfile to accomplish this goal?
The correct answer is A. EXPOSE 8080. The question asks for the correct Dockerfile instruction to declare that a container will listen on a specified network port for intercontainer communication.
Question
Exhibit
Options
- AEXPOSE 8080
- BFIREWALL ADD-PORT 8080
- CPORT 8080
- DOPEN PORT 8080
How the community answered
(22 responses)- A86% (19)
- B9% (2)
- D5% (1)
Why each option
The question asks for the correct Dockerfile instruction to declare that a container will listen on a specified network port for intercontainer communication.
The EXPOSE instruction in a Dockerfile informs Docker that the container listens on the specified network ports at runtime. While it does not actually publish the port, it serves as documentation and allows port mapping with 'docker run -p' or service definitions for intercontainer communication.
FIREWALL ADD-PORT 8080 is not a valid Dockerfile instruction.
PORT 8080 is not a valid Dockerfile instruction; EXPOSE is the correct keyword for this purpose.
OPEN PORT 8080 is not a valid Dockerfile instruction.
Concept tested: Dockerfile EXPOSE instruction
Source: https://docs.docker.com/reference/dockerfile/#expose
Topics
Community Discussion
No community discussion yet for this question.
