aws-cdk-lib.aws_ecs.NetworkMode

enum NetworkMode

LanguageType name
.NETAmazon.CDK.AWS.ECS.NetworkMode
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsecs#NetworkMode
Javasoftware.amazon.awscdk.services.ecs.NetworkMode
Pythonaws_cdk.aws_ecs.NetworkMode
TypeScript (source)aws-cdk-lib » aws_ecs » NetworkMode

The networking mode to use for the containers in the task.

Example

const ec2TaskDefinition = new ecs.Ec2TaskDefinition(this, 'TaskDef', {
  networkMode: ecs.NetworkMode.BRIDGE,
});

const container = ec2TaskDefinition.addContainer("WebContainer", {
  // Use an image from DockerHub
  image: ecs.ContainerImage.fromRegistry("amazon/amazon-ecs-sample"),
  memoryLimitMiB: 1024,
  // ... other options here ...
});

Members

NameDescription
NONEThe task's containers do not have external connectivity and port mappings can't be specified in the container definition.
BRIDGEThe task utilizes Docker's built-in virtual network which runs inside each container instance.
AWS_VPCThe task is allocated an elastic network interface.
HOSTThe task bypasses Docker's built-in virtual network and maps container ports directly to the EC2 instance's network interface directly.
NATThe 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.


BRIDGE

The task utilizes Docker's built-in virtual network which runs inside each container instance.


AWS_VPC

The task is allocated an elastic network interface.


HOST

The task bypasses Docker's built-in virtual network and maps container ports directly to the EC2 instance's network interface directly.

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.

This is the only supported network mode for Windows containers. For more information, see Task Definition Parameters.