iT邦幫忙

2025 iThome 鐵人賽

DAY 9
0

建立 Task Definition(EC2 模式)

  1. ECS → Task definitions → Create new task definition

  2. Familyhello-web

  3. Network mode: bridge ****

  4. Infrastructure requirements(Requires compatibility):選 EC2

    https://ithelp.ithome.com.tw/upload/images/20250919/20161802p4CC0C999l.png

  5. Task size:0.25 vCPU / 0.25 GB Memory (demo所需資源極小, 這邊象徵性填一下)

    https://ithelp.ithome.com.tw/upload/images/20250919/20161802ZLJe3nTWvH.png

  6. Task execution role:選剛才建立的 ecsTaskExecutionRole(讓 ECS 能夠從 ECR 拉 Docker Image)。

    https://ithelp.ithome.com.tw/upload/images/20250919/20161802xBHeLhz4eP.png

  7. Add container

    • Container name:hello

    • Image URI:貼上你剛 push 的 ...amazonaws.com/hello-web:v1

      https://ithelp.ithome.com.tw/upload/images/20250919/20161802eDnN63UeTa.png

    • Port mappings

      • Container port:8000(程式listen的埠)
      • Host port:8080(要對外開的主機埠)
      • Protocol:tcp

      https://ithelp.ithome.com.tw/upload/images/20250919/20161802RRvDdNjeS8.png

    • Log collection:選 awslogs

      (Logging功能後來我最後沒有打開,因為打開Service就會報錯誤,無法順利運作)

      • Log group:/ecs/hello

        (可在這裡輸入名稱讓系統幫你建立,或先去 CloudWatch Logs 建立)

      • Region:ap-northeast-1

      • Stream prefix:app

      https://ithelp.ithome.com.tw/upload/images/20250919/20161802NvLPDiQc3Z.png

      EC2 模式支援 awslogs,可將容器 stdout/stderr 送至 CloudWatch Logs,方便除錯。

  8. Create 送出。


上一篇
Day8 - 建立 ECR 倉庫、撰寫 Hello World Web、推映像
下一篇
Day 10 - 在ECS Cluster 建立 Service
系列文
從零開始:AWS 部署 Python 自動交易程式與交易監測 Dashboard 實戰筆記12
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言