ladderlore
  • 输入服务名称,例如 S3 或 IAM。

概念 · 基于 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.

本课尚未翻译,暂以英文显示。

你在云从业者中已学过

  • 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.
阅读云从业者课程
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.

是什么

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.

是什么

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.

是什么

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.

要记住

  • 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.

要记住

  • 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.

考试中

  • “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.