NetworkMode
- class aws_cdk.aws_ecs.NetworkMode(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
Enum
The networking mode to use for the containers in the task.
- ExampleMetadata:
infused
Example:
ec2_task_definition = ecs.Ec2TaskDefinition(self, "TaskDef", network_mode=ecs.NetworkMode.BRIDGE ) container = ec2_task_definition.add_container("WebContainer", # Use an image from DockerHub image=ecs.ContainerImage.from_registry("amazon/amazon-ecs-sample"), memory_limit_mi_b=1024 )
Attributes
- 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.
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.
- NONE
The task’s containers do not have external connectivity and port mappings can’t be specified in the container definition.