ladderlore
  • Type a service name, like S3 or IAM.

Concept · Builds on CLF-C02

When and how to containerize

When containers beat virtual machines and Lambda, how to move a legacy app into one, and how to choose ECS, EKS and Fargate.

You know from Cloud Practitioner

  • A container image packs code and everything it needs, so it runs the same everywhere.
  • Amazon ECR stores images. Amazon ECS or Amazon EKS orchestrates them.
  • Containers run on AWS Fargate (no servers to manage) or on EC2 instances.
Read the Cloud Practitioner lesson
Short event-driven code?
Lambda
Team uses Kubernetes?
EKS
Need GPUs or special hardware?
ECS or EKS on EC2
ECS on Fargate
yesnoyesnoyesno
A quick way to pick the compute for a workload.
  • Sessions

    Before
    Server memory
    In the container
    ElastiCache or DynamoDB
  • Uploaded files

    Before
    Local disk
    In the container
    S3 or EFS
  • Settings

    Before
    Config file on the server
    In the container
    Environment variables, Secrets Manager
  • Logs

    Before
    Files on disk
    In the container
    Standard output, CloudWatch Logs
  • Install

    Before
    By hand on each server
    In the container
    Image built once, stored in ECR
What changes when a legacy app moves into a container.

1 / 2

  • Sessions

    Before
    Server memory
    In the container
    ElastiCache or DynamoDB
  • Uploaded files

    Before
    Local disk
    In the container
    S3 or EFS
  • Settings

    Before
    Config file on the server
    In the container
    Environment variables, Secrets Manager

2 / 2

  • Logs

    Before
    Files on disk
    In the container
    Standard output, CloudWatch Logs
  • Install

    Before
    By hand on each server
    In the container
    Image built once, stored in ECR
What changes when a legacy app moves into a container.

What it is

Choose containers for many small services, fast start and dense packing, the same package from laptop to production, and code that does not fit Lambda: runs longer than 30 minutes (older exams say 15), a custom runtime or a long-lived process. Choose virtual machines (EC2) when the app needs full control of the operating system or kernel, or has licensing tied to a server. Choose Lambda for short, event-driven code with spiky traffic.

What it is

To move a legacy app into a container, first make it stateless: keep sessions, uploads and files outside the container, in ElastiCache, S3, EFS or a database. Move settings to environment variables or AWS Secrets Manager, not config files baked into the image. Write logs to standard output so the platform collects them. Build the image, store it in Amazon ECR and run it as an ECS service or EKS deployment behind a load balancer. Data written inside a container is lost when it stops.

What it is

ECS is the AWS-native orchestrator with the simplest setup and deep IAM integration. EKS runs Kubernetes: choose it when the team already uses Kubernetes, wants portability, or needs the Kubernetes tools. Fargate removes the servers for either. Choose EC2 capacity when you need GPUs, special instance types, or the lowest cost at a steady high load.

Remember

  • Containers fit microservices, fast scaling, and long-running or custom-runtime code.
  • Make the app stateless before containerizing. Data inside a container is lost when it stops.
  • Settings in environment variables or Secrets Manager. Logs to standard output.
  • Image in ECR, then run on ECS or EKS.

Remember

  • ECS: simplest. EKS: Kubernetes. Fargate: no servers for either. EC2: GPUs and cost control.
  • Each ECS task can have its own IAM role, to follow least privilege.

On the exam

  • “Move a legacy app to AWS with the least operational effort and no servers to manage” points to a container on Fargate.
  • “The company already runs Kubernetes” points to Amazon EKS.
  • “An event-driven job runs for several hours” points to Fargate, not Lambda.
  • “Keep user uploads when containers are replaced” points to Amazon S3 or EFS, not the container disk.