Jarrod Brunson
06/27/2025, 10:34 PMMarvin
06/27/2025, 10:35 PMMarvin
06/27/2025, 10:36 PMSERVER_PORT
environment variable. For example:
yaml
# Task definition excerpt
containerDefinitions:
- name: worker1
environment:
- name: SERVER_PORT
value: "8080"
- name: worker2
environment:
- name: SERVER_PORT
value: "8081"
2. Use awsvpc
Network Mode:
Configure your ECS task to use awsvpc
network mode. This gives each container its own network interface, allowing them to use the same port without conflict. Update your task definition:
json
{
"networkMode": "awsvpc",
"containerDefinitions": [
// your container definitions here
]
}
3. Use Dynamic Port Mapping:
If using bridge
network mode, let Docker assign dynamic host ports:
json
{
"networkMode": "bridge",
"containerDefinitions": [
{
"portMappings": [
{
"containerPort": 8080,
"protocol": "tcp"
}
]
}
]
}
The first option (using different ports) is typically the most straightforward and gives you the most control. Just make sure your task definition's security group allows traffic on both ports if you need external access.
For more details on ECS-specific configurations, you can refer to the Prefect ECS guide.
Would you like me to elaborate on any of these solutions or provide more specific configuration examples for your use case?