Files
Paul Holzinger ca9efb0cda network: document ports and macvlan interaction
The network backend will ignore ports for macvlan and ipvlan networks so
they do not do anything. No warning or error is shown because containers
may be later connected to a bridge network in which case they would be
useful.

Fixes #17927

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-10-19 17:04:29 +02:00

27 lines
1.2 KiB
Markdown

####> This option file is used in:
####> podman create, pod create, run
####> If file is edited, make sure the changes
####> are applicable to all of those.
#### **--publish**, **-p**=*[[ip:][hostPort]:]containerPort[/protocol]*
Publish a container's port, or range of ports,<<| within this pod>> to the host.
Both *hostPort* and *containerPort* can be specified as a range of ports.
When specifying ranges for both, the number of container ports in the
range must match the number of host ports in the range.
If host IP is set to 0.0.0.0 or not set at all, the port is bound on all IPs on the host.
By default, Podman publishes TCP ports. To publish a UDP port instead, give
`udp` as protocol. To publish both TCP and UDP ports, set `--publish` twice,
with `tcp`, and `udp` as protocols respectively. Rootful containers can also
publish ports using the `sctp` protocol.
Host port does not have to be specified (e.g. `podman run -p 127.0.0.1::80`).
If it is not, the container port is randomly assigned a port on the host.
Use **podman port** to see the actual mapping: `podman port $CONTAINER $CONTAINERPORT`.
Note that the network drivers `macvlan` and `ipvlan` do not support port forwarding,
it will have no effect on these networks.