I'm getting this error when running a task on my Amazon Fargate cluster. Has anyone seen run into this before?
问题:
回答1:
Public IP is mandatory for Farget. For details https://github.com/aws/amazon-ecs-agent/issues/1128
回答2:
Go to the docs for an answer to this one.
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_cannot_pull_image.html
Since you are encountering a 500
error, I would heed the advice of the first error's description, "Connection timed out":
When a Fargate task is launched, its elastic network interface requires a route to the internet to pull container images. If you receive an error similar to the following when launching a task, it is because a route to the internet does not exist:
CannotPullContainerError: API error (500): Get https://111122223333.dkr.ecr.us-east-1.amazonaws.com/v2/: net/http: request canceled while waiting for connection
To resolve this issue, you can:
For tasks in public subnets, specify ENABLED for Auto-assign public IP when launching the task...
For tasks in private subnets, specify DISABLED for Auto-assign public IP when launching the task, and configure a NAT Gateway in your VPC to route requests to the internet...
If you encountering any other issues relating to ECS Tasks not starting or exhibiting weird behavior upon starting, then check the full list of ECS troubleshooting topics.
I was encountering a similar error (404
instead of 500
), however, the Task displayed that it was RUNNING even though the detailed status listed an error.
It turns out that the role associated with the task (same role as the EC2 Instance on which it was running, in this case) could not be assumed by ecs-tasks. Adding the following trust relationship statement to the role resolved the issue:
{
"Effect": "Allow",
"Principal": {
"Service": "ecs-tasks.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
See the specific page on the Task Execution Roles for more details.
回答3:
This error occurs when the container is unable to pull the container from the registry.
- Check that you're allocating a public IP address to your containers. Currently the AWS container registry doesn't have an internal-in-vpn endpoint.
- Check that your containers have a way to connect to the internet (eg: nat instance or similar.
- Check that the security group that you have associated with the container allows outbound traffic. If you created the SG with terraform or similar you may find that it's defaulting to having no outbound rules.
回答4:
You have to allocate a Public Ip to your service, you can do it during the Service definition but as far as I know you can not update your service from the update menu.