ContainerNetworkOptions Class
Network options for a container.
public sealed class ContainerNetworkOptionsRemarks
A container joins ContainerNetworkOptions.Network first, when it is set, then every network added with ContainerNetworkOptions.Add or ContainerNetworkOptions.Add, in order.
Properties
| Name | Description |
|---|---|
| Alias | Gets or sets a network alias for the container on ContainerNetworkOptions.Network, or on the default network when ContainerNetworkOptions.Network is not set. |
| Attachments | Gets the networks added with ContainerNetworkOptions.Add and ContainerNetworkOptions.Add. |
| Network | Gets or sets the network the container connects to first. It can also be a network mode, such as host or none. |
Gets or sets a network alias for the container on ContainerNetworkOptions.Network, or on the default network when ContainerNetworkOptions.Network is not set.
public string? Alias { get; set; }Property value
Attachments
ContainerNetworkOptions.csGets the networks added with ContainerNetworkOptions.Add and ContainerNetworkOptions.Add.
public IReadOnlyList<ContainerNetworkAttachment> Attachments { get; }Property value
Network
ContainerNetworkOptions.csMethods
| Name | Description |
|---|---|
| Add(TemporaryNetwork, string[]) | Connects the container to a TemporaryNetwork. The network is created, if needed, when the container is created. |
| Add(string, string[]) | Connects the container to an existing network. |
| Remove(string) | Disconnects the container from a network added with ContainerNetworkOptions.Add or ContainerNetworkOptions.Add. |
Add overloads
Add(TemporaryNetwork, string[])
ContainerNetworkOptions.csConnects the container to a TemporaryNetwork. The network is created, if needed, when the container is created.
public void Add(TemporaryNetwork network, params string[] aliases)Parameters
networkTemporaryNetwork- The network.
aliasesstring[]- The aliases the other containers of the network reach the container by.
Exceptions
ArgumentException- The container already joins the network.
Add(string, string[])
ContainerNetworkOptions.csConnects the container to an existing network.
Parameters
networkstring- The name of the network.
aliasesstring[]- The aliases the other containers of the network reach the container by.
Exceptions
ArgumentException- The container already joins the network.
Remove(string)
ContainerNetworkOptions.csDisconnects the container from a network added with ContainerNetworkOptions.Add or ContainerNetworkOptions.Add.