Lesson 9 / 28
Exposing Ports
Publish container ports to the host with -p and understand what EXPOSE does and does not do.
-p host:container
By default a container's network is isolated. -p 8080:80 forwards your host's port 8080 to the container's port 80.
docker run -d -p 8080:80 nginx
# visit http://localhost:8080 on your hostEXPOSE is just documentation
The Dockerfile's EXPOSE 80 instruction only documents the intended port — it doesn't actually publish it. You still need -p at run time.