> For the complete documentation index, see [llms.txt](https://hyperhq.gitbook.io/docs-hyper-sh/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hyperhq.gitbook.io/docs-hyper-sh/index-1/index-2/port.md).

# Port

If you've built any multi-container applications, chances are you've had to define some rules in order to manage ports. There are several ways to do this:

* `--expose` flag at runtime
* `EXPOSE` instruction in the Dockerfile
* publish ports by using the `-p` or `-P` flags with `hyper run`

**The behavior of container port in Hyper is very simple**:

* All containers in the same network are inter-accessible; all ports are open within the network by default
* `-P` flag publishes all ports exposed by `--expose` flag at runtime, or `EXPOSE` instruction in the Dockerfile
* `-p` creates a port mapping rule like `-p hostPort:containerPort`. `containerPort` is required. If no `hostPort` is specified, Hyper will use the same port as `containerPort`
