Recall & Review
beginner
What does the EXPOSE instruction do in a Dockerfile?
It tells Docker which ports the container will listen on at runtime. It acts as documentation and helps Docker map ports when running containers.
Click to reveal answer
beginner
Does the EXPOSE instruction publish ports to the host machine automatically?
No. EXPOSE only documents the ports. To make ports accessible outside the container, you must use the -p or --publish option with docker run.
Click to reveal answer
intermediate
How do you expose multiple ports in a Dockerfile?
You can use multiple EXPOSE instructions, one per port, or list multiple ports separated by spaces in a single EXPOSE instruction.
Click to reveal answer
beginner
Example: What does this line do? EXPOSE 80 443
It declares that the container listens on ports 80 and 443. This helps users know which ports to map when running the container.
Click to reveal answer
intermediate
Can EXPOSE specify the protocol (TCP/UDP) for a port?
Yes. You can specify the protocol by adding /tcp or /udp after the port number, like EXPOSE 53/udp. If omitted, TCP is assumed.
Click to reveal answer
What is the main purpose of the EXPOSE instruction in a Dockerfile?
✗ Incorrect
EXPOSE documents ports but does not publish them automatically.
How do you make a container port accessible from the host machine?
✗ Incorrect
The -p or --publish option maps container ports to host ports.
Which of these is a valid way to expose ports 80 and 443 in a Dockerfile?
✗ Incorrect
Ports can be listed separated by spaces in one EXPOSE instruction.
What protocol does EXPOSE assume if none is specified?
✗ Incorrect
TCP is the default protocol if none is specified.
Which command publishes container port 8080 to host port 80?
✗ Incorrect
The syntax -p hostPort:containerPort maps ports correctly.
Explain the role of the EXPOSE instruction in a Dockerfile and how it relates to port publishing.
Think about what EXPOSE tells Docker and what it does not do.
You got /3 concepts.
Describe how to expose multiple ports and specify protocols using the EXPOSE instruction.
Consider how to list ports and add protocol details.
You got /3 concepts.