Private ports
Open up to 5 TCP ports on a container. Other containers in the same project connect to NAME:PORT. Ports can also be targets of a network connector.
A container can open private ports. Use them when one container must call another one, for example a bot that calls a search worker. You can also select the port as a target of a network connector.
Open a port
Section titled “Open a port”- In the console, open Containers.
- Select Create container, or select Edit on a container.
- In Ports, enter the port numbers with commas. Example:
8080, 9000. - Save. An edit restarts the container.
Rules:
- 5 ports at most for each container.
- Each port is from 1 to 65535. A port is in the list one time.
- TCP only.
To remove all ports, make the Ports field empty and save.
With the CLI:
pms container create api --image ghcr.io/owner/api:1.0 --size pms-c-250m-512 --port 8080 --port 9000pms container edit api --port 8080pms container edit api --clear-portsIn an edit, --port replaces all ports. --clear-ports removes all ports.
With the API, send ports as a list of numbers. In an update, "ports": [] removes all ports. If you do not send ports, the ports stay the same.
Connect to a port
Section titled “Connect to a port”A container with ports gets an internal name. The name is the container name. The container page shows it as Internal address. The API returns it as internal_host.
Other containers in the same project connect to <internal_host>:<port>. Example: the container search has port 8080. Another container in the project uses:
http://search:8080A container with no ports has no internal name. internal_host is null.
Same project only
Section titled “Same project only”A private port is reachable only from other containers in the same project.
| From | Can connect? |
|---|---|
| A container in the same project | Yes |
| A network connector of the project, for a port that you selected | Yes, only the selected ports |
| A container in another project, also in your account | No |
| Your computer or the internet | No, except through a network connector |
A container name that has ports must be different from the name of a database in the same project.
The same rule is true for databases. See Databases.
Problems
Section titled “Problems”- The name does not resolve, or the connection times out: check that both containers are in the same project, and that the port is in the Ports list.
- The connection is refused: your app must listen on the port. Listen on
0.0.0.0, not on127.0.0.1. - Right after a container starts, the first connection can fail for a few seconds. Retry.