Score:0

AWS ECS Task is stuck at PROVISIONING

kr flag

I have an ECS Cluster with a capacity provider and a service. The capacity provider runs an autoscale group, and when one instance of this group starts, at the end I can see that there are ECS instances avalaible. Actually, I can connect to them through SSH.

The service also runs well, since it creates a new task which is based on a docker image at ERS repository. However, the task never pass from "PROVISIONING", and if I open the task I can see that the container of the task is void and loading. If I enter into my instance, I see the same docker instance if I do docker ps or docker ps -a. If I execute the agent docker exec id_docker /agent I see:

level=info time=2022-05-02T21:16:05Z msg="Successfully got ECS instance credentials from provider: EC2RoleProvider" module=instancecreds.go
level=info time=2022-05-02T21:16:05Z msg="Starting Amazon ECS Agent" version="1.61.0" commit="05730614"
level=info time=2022-05-02T21:16:05Z msg="Loading configuration"
level=info time=2022-05-02T21:16:05Z msg="Successfully got ECS instance credentials from provider: EC2RoleProvider" module=instancecreds.go

If I try with docker exec id_docker bash I get an error:

OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: "bash": executable file not found in $PATH: unknown

What's happening here? Any clue?

Tim avatar
gp flag
Tim
The error message seems to say it can't find the "bash" executable. Does the container have "bash" available and on the path? Does it work if you install bash? If you poke around in the ECS console, clicking around through tasks, you can often find more details of errors but I don't remember exactly where you find them.
kr flag
I cannot see any other logs... I have pull my docker from my ECR repo at amazon, and run it inside the EC2 instance created by the autoscaling group, and it's working fine. So it must be something related with Amazon permissions I guess. I'm using a load balancer, but there's no server on port 80 so is unhealthy in target group. Might be that?
Score:0
kr flag

What I had after doing docker ps wsa in fact ecs-agent, which is something Amazon creates to control the container. That was the stucked part. My docker wasn't even running in fact.

To solve it, when you create the task, in the container options, when you select the ports of the container to redirect to the host, put in your host values a 0. E.g, redirect port 22 to 22 -> 0 to 22. This is a dynamic port mapping in ecs.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.