Class NetworkMode
The networking mode to use for the containers in the task.
Inheritance
Namespace: Amazon.CDK.AWS.ECS
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public sealed class NetworkMode : Enum
Syntax (vb)
Public NotInheritable Class NetworkMode
Inherits
Enum
Remarks
ExampleMetadata: infused
Examples
var ec2TaskDefinition = new Ec2TaskDefinition(this, "TaskDef", new Ec2TaskDefinitionProps {
NetworkMode = NetworkMode.BRIDGE
});
var container = ec2TaskDefinition.AddContainer("WebContainer", new ContainerDefinitionOptions {
// Use an image from DockerHub
Image = ContainerImage.FromRegistry("amazon/amazon-ecs-sample"),
MemoryLimitMiB = 1024
});
Synopsis
Fields
AWS_VPC | The task is allocated an elastic network interface. |
BRIDGE | The task utilizes Docker's built-in virtual network which runs inside each container instance. |
HOST | The task bypasses Docker's built-in virtual network and maps container ports directly to the EC2 instance's network interface directly. |
NAT | The task utilizes NAT network mode required by Windows containers. |
NONE | The task's containers do not have external connectivity and port mappings can't be specified in the container definition. |
value__ |
Fields
AWS_VPC
The task is allocated an elastic network interface.
public const NetworkMode AWS_VPC
Field Value
Type | Description |
---|---|
Network |
BRIDGE
The task utilizes Docker's built-in virtual network which runs inside each container instance.
public const NetworkMode BRIDGE
Field Value
Type | Description |
---|---|
Network |
HOST
The task bypasses Docker's built-in virtual network and maps container ports directly to the EC2 instance's network interface directly.
public const NetworkMode HOST
Field Value
Type | Description |
---|---|
Network |
Remarks
In this mode, you can't run multiple instantiations of the same task on a single container instance when port mappings are used.
NAT
The task utilizes NAT network mode required by Windows containers.
public const NetworkMode NAT
Field Value
Type | Description |
---|---|
Network |
Remarks
This is the only supported network mode for Windows containers. For more information, see Task Definition Parameters.
NONE
The task's containers do not have external connectivity and port mappings can't be specified in the container definition.
public const NetworkMode NONE
Field Value
Type | Description |
---|---|
Network |
value__
public int value__
Field Value
Type | Description |
---|---|
System. |