- Priya
- November 24, 2022
How to Create Task Definitions for Amazon ECS Cluster on AWS
A task definition is required to run Docker containers in Amazon ECS. Docker image to use with each container in task.
The task definition is a text file, in JSON format, that describes one or more containers, up to a maximum of ten, that form your application.
- Login to aws portal.
- Click on Services.
- Under Containers select Elastic Container Registry.
- Click on Task Definitions.
- Click on Create New Task Definition.
- Select Launch type compatibility.
- Click on Next step.
- Provide Task Definition Name.
- Select existing Task role. By default task role is none.
- Select Network Mode. By default network mode is bridge.
- Provide Task memory & Task cpu size.
- Click on Add container.
- Provide container name.
- Provide image URI from ECR.
- Provide Soft & hard memory limits. Soft limit is smaller than hard limit.
- Provide port mapping.
- We can add storage.
- We can send log to Cloudwatch.
- Click on Add.
- We can Add volume.
- Click on Add volume.
- Provide volume name.
- Select volume type like EFS.
- Provide Source Path.
- Click on Add.
- Provide Tag key name & value.
- Click on Create.
- After sometime Task definition is created successfully.
Create Task Definition using Shell
- Setup aws-cli on your system so click on link https://www.hackerxone.com/blog/how-install-configure-aws-cli-ubuntu-1804
- Run the following command:
aws ecs register-task-definition –family <value> –task-role-arn <value> –execution-role-arn <value>–network-mode <value> –container-definitions –name <value> –image <value> –volumes <value> –cpu <value> –memory <value>