Skip to content
docsv0.17.0

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

Parameters of __construct()
NameTypeDescription
$containerintthe port inside the container
$host(int | null)the port on the host, or null when the service is reachable only inside the stack
$protocolstring`tcp` or `udp`

PortMapping::toCompose()

public function toCompose(): string

The mapping as a compose `ports:` entry — `host:container`, with `/udp` when it is not tcp.