AWS › Amazon ECS (Elastic Container Service)

How does networking work for containers running in ECS, particularly with the awsvpc network mode?

Intermediate

Answer

The awsvpc network mode gives each ECS task its own dedicated network interface and private IP address within your VPC, just like an EC2 instance would have, allowing you to apply security groups directly to individual tasks and giving each task full network isolation from other tasks running on the same infrastructure.
{
  "networkMode": "awsvpc",
  "containerDefinitions": [...]
}
Real-world example A financial services company uses the awsvpc network mode so that each ECS task can have its own security group rules, ensuring that only specific approved services can communicate with a task processing sensitive transaction data.

Common follow-ups: What are the other network modes available in ECS besides awsvpc?;How do security groups apply differently across each network mode?