Upgrade to Pro — share decks privately, control downloads, hide ads and more …

コンテナサービス技術基礎 - 用語と構成理解で全体像を掴む

コンテナサービス技術基礎 - 用語と構成理解で全体像を掴む

初学者向けセミナー「これから始める AWS のコンテナサービス活用」の資料です

「タスク定義って何?」「サービスとタスクの違いは?」コンテナサービスの用語で立ち止まっていませんか? Amazon ECS を中心に、基本用語の関係性から、コンテナ設定、ネットワーク構成、スケーリングなど実装時に必要な技術要素まで整理します。

Avatar for Shinya Tada

Shinya Tada

April 14, 2026

Other Decks in Technology

Transcript

  1. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 1 © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. アマゾンウェブサービスジャパン合同会社 2026 年 4 月 14 日 コンテナサービス技術基礎 - 用語と構成理解で全体像を掴む Shinya Tada Solutions Architect
  2. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 2 自己紹介 2 多田 慎也 アマゾンウェブサービスジャパン合同会社 ソリューションアーキテクト 小売・消費財のお客様を中心にご支援しています。 • インフラエンジニア@ SIer • 関西所属
  3. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 3 ・ECS の基本用語と構成要素の関係性を理解する クラスター、サービス、タスク定義、タスク ・「用語の壁」を抜け出す ドキュメントが読める・設計が始められる状態へ 3 本セッションのゴール
  4. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 4 Part1. ECS の全体像を掴む - 基本用語と構成要素 - 起動タイプの違い(EC2 / Fargate / マネージドインスタンス) Part2. ECS の主要な設定を知る - IAM ロール - ネットワークモード - ストレージ - スケーリング - ログ Part3. デモ 4 アジェンダ
  5. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 5 © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. Part1. ECS の全体像を掴む 5
  6. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 6 Amazon ECS の主要な 4 つの構成要素 6 Docker イメージ Docker イメージ 参照 タスク定義 クラスター タスク Elastic Load Balancing (ELB) 参照 サービス タスクを構成するコンテナ群定義 • コンテナ定義(イメージ場所等) • 要求 CPU & メモリ • タスクに割当てるIAMロール • ネットワークモード • etc ... • タスク定義に基づき 起動されるコンテナ群 • タスク内コンテナは 同一ホスト上で実行 • タスク実行コピー数( n 個)を定義 • 起動後、タスク実行コピー数を維持 • ELB と連携 • 起動タイプ(EC2 / Fargate)を設定 • 実行環境の境界 • IAM 権限の境界(クラスターに対する操作) • スケジュールされたタスクの実行を設定可能 コンテナ コンテナ
  7. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 7 用語の関係性を整理する – レストランでの例え 7 Amazon ECS 用語 レストランでの例え 役割 タスク定義 タスク サービス クラスター ※わかりやすさを重視しているため、現実世界の動きとの違いはあります。 レシピ 何度でも使える設計図 出来上がった料理 レシピから作られた実体 ビュッフェコーナー の管理人 常に N 皿を維持し、配膳する レストランそのもの 収容する場所
  8. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 8 タスク定義 = コンテナ(群)の実行単位定義 8 タスクとしてのまとまりを 所定の JSON 書式で定義したもの • 例:Front-end サービス、Back-end サービス、… • family と revision (1から始まる数)で特定 • CloudFormation や CDK、Terraform 等で作成可 能 スタンドアロンタスク or サービスによって、 タスク定義から起動される • 1 つ以上のコンテナを実行するリソース • タスク内のコンテナ群は必ず同じホスト上で実行 • 1つのタスク定義は最大 10 コンテナ指定可能 タスク定義 scorekeep- frontend scorekeep-api 実行 タスク { "family": “scorekeep", "containerDefinitions": [ { "name":“scorekeep-frontend", "image":"xxx.dkr.ecr.us-east-1.amazonaws.com/fe" }, { "name":“scorekeep-api", "image":"xxx.dkr.ecr.us-east-1.amazonaws.com/api" } ] }
  9. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 9 コンテナの実行方法 9 スタンドアロンタスク • タスク定義に従って実行される アプリケーションの実行単位 • タスク定義の一部のパラメータは タスク実行時に上書き可能 • 用途:バッチジョブなど処理が終わると 停止するワークロードなど サービス • 指定した数のタスクを維持する • タスクが失敗/停止した場合は 新しいタスクを起動して置き換え • 用途:Web アプリケーションなど ⻑時間実行するワークロード • ELB との連携 / Auto Scaling 機能 タスク定義 メインのコンテナが 終了するとタスクも停止 タスク タスク サービス タスクが停止すると、 サービスが必要数を維持 desiredCount = 3 run-task count 2
  10. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 10 AWS のコンテナサービス 10 オーケストレーション コンテナのデプロイ、スケジューリング、スケーリング Amazon Elastic Container Service (Amazon ECS) Amazon Elastic Kubernetes Service (Amazon EKS) イメージレジストリ コンテナイメージの格納 Amazon Elastic Container Registry (Amazon ECR) ホスティング コンテナ実行環境 Amazon Elastic Compute Cloud (Amazon EC2) AWS Fargate その他の関連サービス フルマネージド、サービスディスカバリ、モニタリング AWS Cloud Map Amazon CloudWatch Container Insights Red Hat OpenShift Service on AWS (ROSA)
  11. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 11 Amazon ECS on Amazon EC2 の場合 VPC コンテナを実行してください キャパシティも用意してください ENI コンテナホスト コンテナ Amazon ECS Amazon EC2 < Control Plane > Customer Account AWS がお客様のアカウントに コンテナホスト を作成し、 キャパシティを管理 AWS Managed < Data Plane >
  12. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 12 Amazon ECS on AWS Fargate の場合 Customer Account コンテナを AWS Fargate で 実行してください コンテナ AWS Fargate < Control Plane > < Data Plane > VPC ENI AWS Managed サーバーレス お客様アカウントに コンピューティングリソースが存在しない Amazon ECS
  13. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 13 ノードを意識するということ Customer Account Auto Scaling Group ノードのサイジング • 適切なサイズの インスタンスタイプを選択 ノードのスケーリング • コンテナ増減に合わせて ノードも増減 AMI の管理、更新 • ノードをローリング アップデート • ノード上のコンテナを終了、 別ノードで起動
  14. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 14 AWS Fargate コンピューティングリソースが オンデマンドに起動 • コンテナのサイズに合わせた リソース ノードのリソース管理が不要 • スケールイン、アウトの仕組みや調整 • インスタンスサイズの選択 • ノードイメージのアップデート vCPU /メモリ / 実行時間 に応じた課金形態 オンデマンドに リソースを用意 Amazon EKS Amazon ECS AWS Fargate
  15. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 15 AWS Fargate のセキュリティ面でのメリット Fargate Kernel VM コンテナ Kernel VM コンテナ on EC2 • カーネルに脆弱性 -> コンテナから 「エスケープ」できるリスク • パッチ管理はお客様が実施 on AWS Fargate • 1 タスク=1 ホスト(VM)の仕様に より、脆弱性リスクを軽減 • パッチ管理を AWS Managed で提供 EC2 Kernel VM コンテナ コンテナ コンテナ
  16. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 16 Amazon ECS マネージドインスタンス マネージドインスタンス (Managed Instance) とは、Fargate と EC2 起動タイプそれぞれのメリットを 享受できる第 3 の選択肢 AWS Fargate Amazon EC2 ワークロードの要件を満たす インスタンスタイプを自由に選択可能 インスタンス管理(パッチ適用等)は AWS 側が実施 コンソリデーション等の インフラストラクチャ最適化
  17. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 17 Amazon ECS on マネージドインスタンスの場合 VPC コンテナをマネージドインスタンス上 で実行してください ENI コンテナホスト コンテナ Amazon ECS Amazon EC2 < Control Plane > Customer Account AWS がお客様のアカウントに コンテナ ホスト を作成し、キャパシティを管理 EC2 へのログイン不可等の制約があり AWS Managed AWS Managed 詳細は次のセッションをご視聴ください < Data Plane >
  18. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 18 © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. Part2. ECS の主要な設定を知る 18
  19. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 19 2つの IAM ロールについて o タスクロール ロールを使う人:コンテナ内のアプリケーション S3 にファイルを読み書き DynamoDB にデータ操作 SQS メッセージ送受信 など o タスク実行ロール ロールを使う人:タスクを管理するエージェント ECR からイメージを Pull CloudWatch Logs にログ送信 Secrets Manager から取得 など コンテナホスト タスク ECS コンテナエージェント / Fargate エージェント タスクロール タスク実行ロール
  20. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 20 ネットワークモードとユースケース awsvpc モード (推奨) o ECS 管理下の ENI(仮想サーバーの仮想ネット ワークカード)がタスクにアタッチされる o ユースケース:汎用的 bridge モード o 仮想ネットワークブリッジを利用してホスト/ コンテナポートをマッピングして通信 o ユースケース:デプロイ速度を最優先、 ENIを節約したい場合 host モード o コンテナをホストしている EC2 インスタンスの IP/ポートを介して通信 o ユースケース:awsvpc や Bridge が使えない個別要件がある場合 EC2 instance ENI Port 3000 IP x.x.x.x Port 3000 EC2 instance ENI Port 3000 Port 3000 IP x.x.x.x Port 50077 IP x.x.x.x Port 52330 EC2 instance ENI Port 3000 Port 3000 IP x.x.x.x Port 3000 IP y.y.y.y Port 3000 ENI https://docs.aws.amazon.com/ja_jp/AmazonECS/latest/developerguide/task-networking.html
  21. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 21 ネットワークモード:選択の仕方 Fargate https://docs.aws.amazon.com/AmazonECS/latest/developerguide/fargate-task-networking.hml EC2 https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-networking.html マネージドインスタンス https://docs.aws.amazon.com/AmazonECS/latest/developerguide/managed-instance-networking.html ネットワークモード Fargate (Linux / Windows) EC2 (Linux) EC2 (Windows) マネージドインスタンス (Linux) awsvpc bridge host
  22. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 22 ストレージオプション(一部) Fargate エフェメラルストレージ / バインドマウント o タスクに割り当てられる揮発性のディスク領域 o タスクが停止するとデータが削除される o 20GiB はタスク料金に含む、追加分にのみ課金 (最大 200GiB) EC2 バインドマウント o ホストマシン上のファイルやディレクトリをコンテナにマウント o タスク定義によってデータをホストのライフサイクルに関連付けが可能 Amazon EFS ボリューム o ストレージ容量が伸縮自在で、自動的に拡大および縮小される Amazon EBS ボリューム o 高スループットなトランザクション集約型アプリケーション向け o タスクごとに1つの EBS ボリュームにアタッチ可能
  23. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 23 ストレージオプション:選択の仕方 https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_data_volumes.html ストレージ Fargate (Linux) Fargate (Win) EC2 (Linux) EC2 (Win) マネージド インスタンス (Linux) 永続性 共有スコープ Amazon EBS スタンドアロン タスクのみ 同一タスク内のコンテナ間 Amazon EFS 永続 複数タスク間で同時アクセス可 FSx for Windows 永続 複数タスク間で同時アクセス可 FSx for NetApp ONTAP 永続 複数タスク間で同時アクセス可 Amazon S3 Files 永続 複数タスク間で同時アクセス可 Docker Volume 設定次第 同一ホスト内のタスク間 Bind Mount エフェメラル 同一タスク内のコンテナ間 Instance Store エフェメラル 同一インスタンス内 Ephemeral Storage - - - エフェメラル 共有不可
  24. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 24 スケーリング設定 CPU 必要タスク数 (DesiredCount) Traffic Time 100% 0% 50% 10% 20% 30% 40% 60% 70% 80% 90% 5 30 10 15 20 25 Target CPU Utilization DesiredCount( 自動調整) ターゲット追跡スケーリングポリシー の動作イメージ 1. ターゲット追跡スケーリングポリシー • 指定したメトリクスがターゲットの値に近づく ように自動的に調整 2. ステップスケーリングポリシー • アラームをトリガーに調整値に基づいて増減 • ターゲット追跡スケーリングポリシーと組み合 わせることでより高度なスケーリングも可能 3. スケジュールに基づくスケーリング • 日付と時刻に基づいてタスク数を増減 4. 履歴に基づく予測スケーリング • 日次または週次の過去の負荷データ分析に基づ いて、サービスが実行するタスク数を増減 https://docs.aws.amazon.com/ja_jp/AmazonECS/latest/developerguide/service-auto-scaling.html 併 用 可
  25. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 25 ECS における代表的なロギング戦略 Amazon ECS AWS Fargate アプリケーションコンテナ コンテナランタイム (Containerd) CloudWatch Logs 標準出力・ 標準エラー出力 Amazon ECS AWS Fargate アプリケーションコンテナ コンテナランタイム (Containerd) 標準出力・ 標準エラー出力 FireLens コンテナ awslogs awsfirelens (Fluent Bit) Amazon Kinesis Data Streams Amazon S3 CloudWatch Logs Amazon Data Firehose
  26. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 26 ロギング戦略 Pros. Cons. awslogs ログドライバー FireLens ログドライバー • 設定がシンプル • サイドカーコンテナ不要 • 送信先は CloudWatch Logs のみ • ログの加工やフィルタリングは不可 • 柔軟性が高い • ログルーターとの接続が容易 • Fluentd または Fluent Bit が必要 • 設定ファイルの管理が発生
  27. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 27 メトリクス Container Insights クラスター設定で有効化するだけで、CPU・メモリ・ネットワーク等の メトリクスを自動収集し、CloudWatch ダッシュボードで可視化できます。 デフォルトは OFF
  28. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 28 © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. Part3. デモ 28
  29. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 29 デモ構成 AWS Cloud Private subnet Public subnet Application Load Balancer Private subnet Public subnet User Amazon ECS クラスター AWS Fargate Container Container AWS Fargate Amazon ECR Virtual private cloud (VPC)
  30. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 30 0.事前準備 AWS Cloud Private subnet Public subnet Application Load Balancer Private subnet Public subnet Amazon ECR Virtual private cloud (VPC) コンテナイメージ ALB用SG コンテナ用SG .
  31. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 31 1.ECS クラスター作成 AWS Cloud Private subnet Public subnet Application Load Balancer Private subnet Public subnet Amazon ECR Virtual private cloud (VPC) コンテナイメージ ALB用SG Amazon ECS クラスター コンテナ用SG .
  32. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 33 2.タスク定義作成 AWS Cloud Private subnet Public subnet Application Load Balancer Private subnet Public subnet Amazon ECR Virtual private cloud (VPC) コンテナイメージ ALB用SG Amazon ECS クラスター タスク定義 コンテナ用SG .
  33. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 35 3.ECS サービス作成 AWS Cloud Private subnet Public subnet Application Load Balancer Private subnet Public subnet Amazon ECR Virtual private cloud (VPC) コンテナイメージ ALB用SG Amazon ECS クラスター タスク定義 AWS Fargate Container Container AWS Fargate コンテナ用SG .
  34. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 37 4.動作確認 AWS Cloud Private subnet Public subnet Application Load Balancer Private subnet Public subnet User Amazon ECR Virtual private cloud (VPC) コンテナイメージ ALB用SG コンテナ用SG . Amazon ECS クラスター タスク定義 AWS Fargate Container Container AWS Fargate
  35. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 39 © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. まとめ 39
  36. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 40 Part1. ECS の全体像を掴む - 基本用語と構成要素 - 起動タイプの違い(EC2 / Fargate / マネージドインスタンス) Part2. ECS の主要な設定を知る - IAM ロール - ネットワークモード - ストレージ - スケーリング - ログ Part3. デモ 40 アジェンダ 再掲
  37. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 41 ・ECS の基本用語と構成要素の関係性を理解する クラスター、サービス、タスク定義、タスク ・「用語の壁」を抜け出す ドキュメントが読める・設計が始められる状態へ 41 本セッションのゴール 再掲
  38. © 2026, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 42 Thank you! © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved.