beginnerDockerfile Instructions & Multi-Stage Builds

Does EXPOSE actually publish a port?

No. EXPOSE is documentation/metadata recorded in the image — useful for tools and humans reading the Dockerfile, and used by docker run -P (publish all exposed ports to random host ports). Actually making a port reachable from outside the container requires -p hostPort:containerPort at docker run or a ports: entry in Docker Compose.

This is a Pro chapter

Sign in, then upgrade to Pro or Power to unlock this and the full DevOps Mastery library.

Does EXPOSE actually publish a port?

Next Step

Continue to Why should you use exec form instead of shell form for ENTRYPOINT/CMD?← Back to all Docker questions