I misunderstood Amazon's documentation. "Private Ipv4 addresses per interface" is not related to the ENI limit for an EC2 instance.
aws ec2 describe-instance-types --filters Name=instance-type,Values=t3.* --query "InstanceTypes[].{Type: InstanceType, MaxENI: N
etworkInfo.MaximumNetworkInterfaces, IPv4addr: NetworkInfo.Ipv4AddressesPerInterface}" --output table
--------------------------------------
| DescribeInstanceTypes |
+----------+----------+--------------+
| IPv4addr | MaxENI | Type |
+----------+----------+--------------+
| 12 | 3 | t3.large |
| 15 | 4 | t3.2xlarge |
| 6 | 3 | t3.medium |
| 15 | 4 | t3.xlarge |
| 4 | 3 | t3.small |
| 2 | 2 | t3.micro |
| 2 | 2 | t3.nano |
+----------+----------+--------------+
It is the MaxENI column here (or the 'Maximum Network Interfaces') that is the limit.
In other words, my t3.small instance (and the t3.medium and t3.large instances that I subsequently tested) all have a MaxENI of 3, so can only run 2 containers with awsvpc networking. A t3.xlarge (4vCPU, 16GiB RAM) instance can run 3 containers (also confirmed).
Amazon have a feature called Elastic network interface trunking which can raise this limit, described here. The introductory paragraph states:
For example, by default a c5.large instance may have up to three ENIs attached to it. The primary network interface for the instance counts as one, so you can attach an additional two ENIs to the instance. Because each task using the awsvpc network mode requires an ENI, you can typically only run two such tasks on this instance type.
... exactly my problem. The page continues:
Amazon ECS supports launching container instances with increased ENI density using supported Amazon EC2 instance types. When you use these instance types and opt in to the awsvpcTrunking account setting, additional ENIs are available on newly launched container instances. This configuration allows you to place more tasks using the awsvpc network mode on each container instance. Using this feature, a c5.large instance with awsvpcTrunking enabled has an increased ENI limit of twelve.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…