5

I have an ECS cluster with ELB. Last night I saw that a task was stuck in restarting loop. From the service Events log, it said:

"service xxxxx was unable to place a task because no container instance met all of its requirements. The closest matching container-instance xxxxxxxxxxxxxx is already using a port required by your task."

However, I have checked that all such tasks are dead and nothing should be using the port at that time. Updating the service does not help but creating new task definition and then update helps. Terminating the instance and allow ELB to relaunch it helps.

Any idea why the service cannot secure the port for the task?

enter image description here

M. Glatki
  • 1,868
  • 1
  • 16
  • 33
billyklh
  • 51
  • 2
  • The following information is needed to answer this: What is the port mapping configuration on your ecs task (dynamic vs. static)? How many EC2 hosts do you have, how many tasks are runing on the cluster? – M. Glatki Jun 22 '18 at 09:17

1 Answers1

0

I think your problem is the task definition "Network mode" is host or something that works equally, this causes the host port to be already in use when ECS fires deployment.

The way ECS deploys is using your minimum healthy percent, so if you have more than 0%, it needs to start the new task before stopping the old one. In this case, it cant bind the host port on the new task because its in use by the old one.

Try using another Network mode that don't lock host port, like "awsvpc"

Hope it helps!

Ayozemr
  • 1
  • 1