EXPOSE
The Dockerfile instruction that documents which port the application listens on; it does not publish anything.
In more detail
EXPOSE 8000 is a note for people and tools. To reach the service from the host you still publish a port with -p when running (or -P, which publishes every exposed port to a random host port).
Example
EXPOSE 8000Related terms
- port publishing — Forwarding a port on the host to a port inside a container so the service can be reached from outside.
- port — A number from 1 to 65535 that picks out one service on a machine, such as 22 for SSH or 80 for plain web traffic.
Taught in
- Container Images The Exam Way — Certified Kubernetes Application Developer (CKAD) Exam Prep
- ARG, ENV, LABEL, EXPOSE And VOLUME — Docker Architecture & Production Containers
- Port Publishing, Localhost And Network Troubleshooting — Docker Architecture & Production Containers
- Twelve Lines, Ten Warnings: Dockerfile Instructions And hadolint — Docker Certified Associate (DCA) Exam Prep
- It Works On The Host: Publishing Ports And Tracing Connections — Docker Certified Associate (DCA) Exam Prep