I've created an ECS Service with a task definition that contains two containers. The first is the xray-daemon, and the second is my application (Python, Flask). The task starts fine; however, the application container gives me the following error in the logs.
botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:2000/GetSamplingRules"
I've tried to do a port mapping on the xray-daemon
container to 2000/tcp and followed the documentation to link the two containers specified here.
Any suggestions/thoughts on how to fix this?
Below is my task definition:
{
"family": "app-api",
"containerDefinitions": [
{
"name": "xray-daemon",
"image": "public.ecr.aws/xray/aws-xray-daemon:latest",
"cpu": 32,
"memoryReservation": 256,
"environment": [
{
"name": "AWS_REGION",
"value": "us-east-1"
}
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/aws-xray-daemon-app-api",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "ecs"
}
},
"portMappings" : [
{
"hostPort": 0,
"containerPort": 2000,
"protocol": "udp"
},
{
"hostPort": 0,
"containerPort": 2000,
"protocol": "tcp"
}
]
},
{
"name": "app-api",
"image": "XXXXXXXXXXXX.dkr.ecr.us-east-1.amazonaws.com/app-api:latest",
"cpu": 0,
"environment": [
{ "name" : "AWS_REGION", "value" : "us-east-1" },
{ "name" : "NOTIFICATION_TOPIC", "value" : "arn:aws:sns:us-east-1:XXXXXXXXXXXX:app-api" },
{ "name" : "AWS_XRAY_DAEMON_ADDRESS", "value" : "xray-daemon:2000" }
],
"portMappings": [
{
"containerPort": 5000,
"hostPort": 8082,
"protocol": "tcp"
}
],
"links":["xray-daemon"],
"essential": true,
"environment": [],
"mountPoints": [],
"volumesFrom": [],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/app-api",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "ecs"
}
}
}
],
"networkMode": "bridge",
"requiresCompatibilities": [
"EXTERNAL"
],
"taskRoleArn": "arn:aws:iam::XXXXXXXXXXXX:role/rol_XXXXXXXXXXXX",
"executionRoleArn": "arn:aws:iam::XXXXXXXXXXXX:role/rol_XXXXXXXXXXXX",
"cpu": "1024",
"memory": "1024"
}