5

I am trying to set up an AWS service with autoscaling. I have created a cluster with an application loadbalancer and created a task using a docker image that should be open on port 8080 for use. I have created a service based on that task for which I have set minimum and desired number of instances to 1 and maximum to 10, and created rules for scaling up and down. However, no new instances are created and all I get in the list of events at regular intervals is:

service microrecieverservice was unable to place a task because no container instance met all of its requirements. The closest matching container-instance 97d97ce9-967d-49ad-83ad-f4f904aae1f6 is already using a port required by your task. For more information, see the Troubleshooting section.

I have not been able to find anything relevant in the troubleshooting section. I have been able to manually add another instance to the cluster, but with no change in the events given. I could ssh into this instance, and there were two docker images: one was amazon-ecs-agent:latest and the other was my task definition. At this point I tried sending a REST request to the server to see if it would go through but got Connection Refused. At about the same time, the docker image restarted.

The container is not running anything else that would use port 8080 and when I do netstat -lntp the process using port 8080 is that of the my docker image.

Andrew Schulman
  • 8,561
  • 21
  • 31
  • 47
  • Do both instances show as being part of the cluster in the ECS UI? If you want to be able to deploy multiple instances of the same task to the same EC2 instance, you need to use dynamic port mapping. – jordanm Feb 26 '18 at 18:41
  • @jordanm They do show as being part of the same cluster. I don't want them to be in the same EC2 instance, but to start new instances as necessary and deploy the task to them. – Jonathan Coustick Feb 27 '18 at 09:09

1 Answers1

0

Most likely, your task uses port 8080 as a static port.

Since you have only one instance in your cluster, you can not update your service while still adhering to your placement strategy, which most likely requires to start the new task first, wait for the health check to succeed, than to stop the old task.

With the only instance having a task running on port 8080, there is no instance available on which the task can be started.

Use ECS dynamic port mapping, or start more instances in your cluster.

M. Glatki
  • 1,868
  • 1
  • 16
  • 33