ECS, ECR & Fargate - Docker in AWS Flashcards
How is Docker different from a Virtual Machine?
Resources are shared with the host -> many containers on one server
How does the EC2 Launch type work?
You must provision & maintain the infrastructure - the EC2 instances
- Each EC2 instance must run the ECS agent to register in the ECS cluster
- AWS starts/stops docker containers on the provisioned instances.
How does ECS Fargate Launch type differ from EC2 Launch type?
You do not provision the infrastructure - no EC2 instances to manage.
- Serverless launch type
What is the EC2 Instance Profile used by and for?
EC2 Launch Type only:
- Used by the ECS agent
- Makes API calls to the ECS service
- Send container logs to CloudWatch logs
- Pull Docker image from ECR
- Reference sensitive data in Secrets Manager or SSM Parameter Store
What is the ECS Task Role?
- Allows each task to have a specific role (e.g., one task might fetch from S3, another from DynamoDB
If you were to integrate ECS with a load balancer, which would be recommended out of ALB, NLB and Elastic Load Balancer and why?
ALB - works for most use cases
NLB - recommended only for high throughput / performance use cases, or to pair it with AWS Private Link
ELB - no advanced features, no Fargate
What does EFS stand for?
Elastic File System
What is a use case for EFS, and why not S3?
Persistent multi-AZ shared storage for your containers - mount the EFS onto ECS tasks (works for both launch types), and any AZ will share the same data in the file system
- S3 cannot be mounted as a file system
What options can you scale on for ECS Application Auto Scaling?
- ECS service average CPU utilization
- ECS service average memory utilization (RAM)
- ALB Request count per target (metric from the ALB)
What is Target Tracking?
Scale based on a target value for a Cloudwatch metric
What is Step Scaling?
Scale based on a specific Cloudwatch alarm
What is Scheduled Scaling?
Scale based on a specified data/time (predictable changes)
What is the difference between ECS Service Auto Scaling and EC2 Auto Scaling?
ECS Service Auto Scaling - Fargate scales the number of taskst
EC2 Auto Scaling - EC2 scales the number of instances
Describe two ways of Auto Scaling EC2 Instances
Auto Scaling Group Scaling:
- Scale your ASG based on CPU Utilization
- Add EC2 instances over time
ECS Cluster Capacity Provider
- Automatically provision and scale the infrastructure for you ECS tasks
- Capacity Provide is paired with an ASG
- Add EC2 instances when you’re missing capacity (CPU, RAM)
What is ECS Rolling Update?
Update from V1 to V2
Set min and max percentage of healthy tasks
- ECS will scale to provide new V2 tasks
- Terminate some V1 tasks, ECS will again scale to provide new V2 tasks
- Repeat until all tasks at V2
What are Task Definitions?
Metadata in JSON form to tell ECS how to run a docker container.
What information is listed in a Task Definition?
- Image name
- Port Binding for Container and Host
- Memory and CPU required
- Environment variables
- Networking information
- IAM role
- Logging configuration (e.g., Cloudwatch)