PortMapping
A port a service listens on inside its container, and the host port it is published on, if any.
PortMapping::__construct()
public function __construct(int $container, ?int $host = null, string $protocol = 'tcp'):Parameters
| Name | Type | Description |
|---|---|---|
| $container | int | the port inside the container |
| $host | (int | null) | the port on the host, or null when the service is reachable only inside the stack |
| $protocol | string | `tcp` or `udp` |
PortMapping::toCompose()
public function toCompose(): stringThe mapping as a compose `ports:` entry — `host:container`, with `/udp` when it is not tcp.