r/aws•
netquestioner

ECS Task Definitions

containers

Hello,

Can you control the following?

1 Service that requires 4 tasks running on one ECS instance to run on separate Containers within.

I noticed that this may be able to be defined in the Task Definition but couldn't quite find it. Currently I find that all 4 tasks are running within the same container.

Posted Apr 29, 2020, 3:53 AM UTC

10

You should really understand what a service, task, container, and task definition are. That will literally answer your question

2
netquestionerOP•

Thanks. I think my confusion was mainly around ECS Instance = Container Instance as defined in the management console. You don't get to see the actual individual containers in the console.

1

you see the containers when you click on the task, or in the task definition view

​

Services launch tasks based on a task definition. Tasks/definitions container one or more containers

​

container instance == ec2 instance running ecs agent connected to your ecs cluster

2
netquestionerOP•

Yep, thanks for the explanation.

As far as hard/soft limits only hard memory limits will actually terminate a container or task, not a CPU hard limit right?

1
Scarface74•

What do you mean that all four tasks are running in the same container? They are all running on the same VM? If you want the containers not to be dependent on each other, create separate services.

1
netquestionerOP•

They're all running on the same ECS host. So the only way to have a task run on a different container (not ecs host) is to define another service?

1
Scarface74•

I think there is some confusion on terminology. I’ve only used Fargate.

Grossly simplified:

  • a container image is like a disk image. Nothing runs on an image. Just like you attach a disk image to a VM to run, you tell Docker to run your image.

  • task definition - defines the environment or VM constraints of the tasks. You specify one or more container images, the CPU and memory needed. If one running process defined by a container fails, the task fails.

  • service defines how many instances of the tasks should run, which cluster they should run on, load balancers it should use, how they should scale, how the tasks should autoscale.

So, if you want your containers to fail independently, they should be separate services. How different services communicate with each other is another topic. Since I have only used Fargate which only supports VPC network mode. I can’t help with that.

https://aws.amazon.com/blogs/compute/introducing-cloud-native-networking-for-ecs-containers/

1