I'm trying to deploy a sample application to AWS ECS and I'm experimenting something weird.
I have created a task definition with a container definition using the sample image amazon/amazon-ecs-sample
. This is just a simple PHP welcome page.
When I start a task in my ECS service, I navigate to the task public IP and it works fine: I can see PHP website. But, eventually, after 2 minutes or so, it stops working and when I reaload I get timeout.
Task is still running and there are no logs. After watching metrics with container insights and CloudWatch metrics, there are no problems with memory or CPU, either.
I'm running my task in Fargate mode and I'm not using load balancer.
This is the task definition:
{
"ipcMode": null,
"executionRoleArn": "arn:aws:iam::xxxxxxxxxxxx:role/myEcsExecutionRole",
"containerDefinitions": [
{
"dnsSearchDomains": [],
"environmentFiles": [],
"logConfiguration": {
"logDriver": "awslogs",
"secretOptions": [],
"options": {
"awslogs-group": "myapp",
"awslogs-region": "eu-central-1",
"awslogs-stream-prefix": "myapp"
}
},
"entryPoint": [],
"portMappings": [
{
"hostPort": 80,
"protocol": "tcp",
"containerPort": 80
}
],
"command": [],
"linuxParameters": null,
"cpu": 512,
"environment": [],
"resourceRequirements": null,
"ulimits": [],
"dnsServers": [],
"mountPoints": [],
"workingDirectory": null,
"secrets": [],
"dockerSecurityOptions": [],
"memory": null,
"memoryReservation": 1024,
"volumesFrom": [],
"stopTimeout": null,
"image": "amazon/amazon-ecs-sample",
"startTimeout": null,
"firelensConfiguration": null,
"dependsOn": null,
"disableNetworking": null,
"interactive": null,
"healthCheck": null,
"essential": true,
"links": [],
"hostname": null,
"extraHosts": [],
"pseudoTerminal": null,
"user": null,
"readonlyRootFilesystem": null,
"dockerLabels": {},
"systemControls": [],
"privileged": null,
"name": "myContainerDefinition"
}
],
"placementConstraints": [],
"memory": "4096",
"taskRoleArn": "arn:aws:iam::xxxxxxxxxxxx:role/myTaskRole",
"compatibilities": [
"EC2",
"FARGATE"
],
"taskDefinitionArn": "arn:aws:ecs:eu-central-1:xxxxxxxxxxxx:task-definition/my-taskdefinition:36",
"family": "my-taskdefinition",
"requiresAttributes": [
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.logging-driver.awslogs"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "ecs.capability.execution-role-awslogs"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.17"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.21"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.task-iam-role"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "ecs.capability.task-eni"
}
],
"pidMode": null,
"requiresCompatibilities": [
"FARGATE"
],
"networkMode": "awsvpc",
"cpu": "2048",
"revision": 36,
"status": "ACTIVE",
"inferenceAccelerators": null,
"proxyConfiguration": null,
"volumes": []
}
EDIT:
This is so weird. I have changed my region from eu-central-1 to eu-west-1 and it's working fine! This problem only happens on eu-central-1.