Interview Prep/Docker/Dockerfile Instructions & Builds

What does `EXPOSE` actually do?

IntermediateConceptDockerfile Instructions & Builds
Answer

It is documentation metadata only; it does not publish the port. -p host:container publishes. -P publishes all EXPOSEd ports to random high host ports. Tools and Compose can use the metadata, but traffic from other containers on the same network works without it.

All Docker questions Roadmap: Docker & containers

More on Dockerfile Instructions & Builds