Back to results for “Elastic Container Registry (ECR)”
AWS › Amazon ECS (Elastic Container Service)

What is a task definition in ECS and what does it contain?

Intermediate

Answer

A task definition is a blueprint that describes how a container should run, including which Docker image to use, how much CPU and memory to allocate, networking configuration, environment variables, and logging settings, and ECS uses this definition every time it launches a new task or scales your service up.
{
  "family": "web-app",
  "containerDefinitions": [{
    "name": "web",
    "image": "myrepo/web-app:latest",
    "memory": 512,
    "cpu": 256
  }]
}
Real-world example A development team updates a task definition to point to a new Docker image version, then deploys that updated task definition to their ECS service, which gradually replaces old running containers with new ones.

Common follow-ups: How do you update a running service to use a new task definition revision?;Can a single task definition run multiple containers together?