ContainerPortCollection Class

A collection of ports published by a container. A container port is published on a single host port.

public sealed class ContainerPortCollection : IEnumerable<ContainerPort>, IEnumerable
Implements

Properties

NameDescription
CountGets the number of ports in the collection.

Gets the number of ports in the collection.

public int Count { get; }

Property value

int

Methods

NameDescription
Add(ContainerPort)Adds a port mapping.
Add(int)Publishes a container port on a random host port.
Add(int, int)Publishes a container port on a specific host port.
GetEnumerator()Returns an enumerator over the port mappings.
Remove(int)Removes the mapping that publishes the specified container port.
System.Collections.IEnumerable.GetEnumerator()

Add overloads

Add(ContainerPort)

ContainerPortCollection.cs

Adds a port mapping.

public void Add(ContainerPort port)
Parameters
port ContainerPort
The port mapping.
Exceptions
ArgumentException
The container port is already published.

Publishes a container port on a random host port.

public void Add(int containerPort)
Parameters
containerPort int
The container port to publish.
Exceptions
ArgumentException
The container port is already published.

Publishes a container port on a specific host port.

public void Add(int hostPort, int containerPort)
Parameters
hostPort int
The host port to bind.
containerPort int
The container port to publish.
Exceptions
ArgumentException
The container port is already published.

Returns an enumerator over the port mappings.

public IEnumerator<ContainerPort> GetEnumerator()

Returns

IEnumerator<ContainerPort> An enumerator.

Removes the mapping that publishes the specified container port.

public bool Remove(int containerPort)

Parameters

containerPort int
The container port to remove.

Returns

bool true if the mapping was removed; otherwise, false.

System.Collections.IEnumerable.GetEnumerator()

ContainerPortCollection.cs
IEnumerator IEnumerable.GetEnumerator()

No documentation is available.