Introduction
When you run an app inside a container, it often listens on a port. The EXPOSE instruction in a Dockerfile tells Docker which port the app will use, so you can connect to it from outside the container.
When you want to tell Docker which port your app inside the container listens on.
When you plan to map container ports to your computer or server ports.
When you want to document the ports your containerized app uses for others.
When you build a Docker image that will run a web server or API service.
When you want to make sure your container’s network traffic is accessible.