

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 將您的 Elastic Beanstalk 應用程式從 AL1 上的 ECS 受管多容器 Docker 遷移至 Amazon Linux 2023 上的 ECS
<a name="migrate-to-ec2-AL2-platform"></a>

**注意**  
2[022 年 7 月 18](https://docs.aws.amazon.com/elasticbeanstalk/latest/relnotes/release-2022-07-18-linux-al1-retire.html) 日，Elastic Beanstalk 會根據 Amazon Linux AMI (AL1) 將所有平台分支的狀態設定為**已淘汰**。

本主題會引導您將應用程式從在 *64 位元 Amazon Linux 上執行的已淘汰平台分支多容器 Docker *遷移至*在 64 位元 AL2023 上執行的 ECS*。這是最新且受支援的目標平台分支。類似於舊版*多容器 Docker AL1* 分支，新版 *ECS AL2023* 平台分支使用 Amazon ECS 來協調將多個 Docker 容器部署至 Elastic Beanstalk 環境內的 Amazon ECS 叢集。新版 *ECS AL2023* 平台分支支援舊版*多容器 Docker AL1* 平台分支中的所有功能。此外支援同樣的 `Dockerrun.aws.json` v2 檔案。

**Topics**
+ [使用 Elastic Beanstalk 主控台遷移](#migrate-to-ec2-AL2-platform-steps-console)
+ [使用 遷移 AWS CLI](#migrate-to-ec2-AL2-platform-steps-cli)

## 使用 Elastic Beanstalk 主控台遷移
<a name="migrate-to-ec2-AL2-platform-steps-console"></a>

若要使用 Elastic Beanstalk 主控台進行遷移，請將相同的原始程式碼部署到以*執行於 AL2023 的 ECS* 平台分支為基礎的新環境。無需變更原始程式碼。

**遷移到*執行於 Amazon Linux 2023 的 ECS* 平台分支**

1. 使用已部署到舊環境的應用程式原始碼套件建立應用程式原始碼。您可以使用相同的應用程式原始碼套件和相同的 `Dockerrun.aws.json`v2 檔案。

1. 使用*執行於 Amazon Linux 2023 的 ECS* 平台分支建立新環境。使用先前步驟所述**應用程式的程式碼**中的原始碼套件。如需詳細步驟，請參閱本章前面所述 *ECS 受管 Docker 教學*中的 [部署到 Elastic Beanstalk](create_deploy_docker_ecstutorial.md#create_deploy_docker_ecstutorial_deploy)。

## 使用 遷移 AWS CLI
<a name="migrate-to-ec2-AL2-platform-steps-cli"></a>

您也可以選擇使用 AWS Command Line Interface (AWS CLI) 將現有的*多容器 Docker Amazon Linux Docker* 環境遷移至較新的 *ECS AL2023* 平台分支。在此情況下，您無需建立新的環境或重新部署您的原始程式碼。您只需要執行 AWS CLI [update-environment](https://docs.aws.amazon.com/cli/latest/reference/elasticbeanstalk/update-environment.html) 命令。這會執行平台更新，以將現有的環境遷移至 *ECS Amazon Linux 2023* 平台分支。

使用以下語法將您的環境遷移至新的平台分支。

```
aws elasticbeanstalk update-environment \
--environment-name {{my-env}} \
--solution-stack-name "64bit Amazon Linux 2023 {{version}} running ECS" \
--region {{my-region}}
```

以下是在 *us-east-1* 區域將環境 *beta-101* 遷移至 *3.0.0 版* *ECS Amazon Linux 2023* 平台分支的命令範例。

```
aws elasticbeanstalk update-environment \
--environment-name beta-101 \
--solution-stack-name "64bit Amazon Linux 2023 v4.0.0 running ECS" \
--region us-east-1
```

`solution-stack-name` 參數提供了平台分支及其版本。透過指定適當的*解決方案堆疊名稱*，使用最新的平台分支*版本*。每個平台分支的版本均包含在*解決方案堆疊名稱*內，如上例所示。如需 Docker 平台的最新解決方案堆疊清單，請參閱 *AWS Elastic Beanstalk 平台*指南中的[支援的平台](https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html#platforms-supported.docker)。

**注意**  
 [list-available-solution-stacks](https://docs.aws.amazon.com/cli/latest/reference/elasticbeanstalk/list-available-solution-stacks.html) 命令提供適用於您 AWS 區域中帳戶的平台版本清單。  

```
aws elasticbeanstalk list-available-solution-stacks --region us-east-1 --query SolutionStacks
```

若要進一步了解 AWS CLI，請參閱 [https://docs.aws.amazon.com//cli/latest/userguide/cli-chap-welcome.html](https://docs.aws.amazon.com//cli/latest/userguide/cli-chap-welcome.html)。如需 Elastic Beanstalk AWS CLI 命令的詳細資訊，請參閱 [https://docs.aws.amazon.com//cli/latest/reference/elasticbeanstalk/index.html](https://docs.aws.amazon.com//cli/latest/reference/elasticbeanstalk/index.html)。