

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 在亚马逊 Linux 2023 上将你的 Elastic Beanstalk 应用程序从 ECS 托管的多容器 Docker AL1 迁移到 ECS
<a name="migrate-to-ec2-AL2-platform"></a>

**注意**  
[2022 年 7 月 18 日，](https://docs.amazonaws.cn/elasticbeanstalk/latest/relnotes/release-2022-07-18-linux-al1-retire.html)**Elastic Beanstalk 将所有基于亚马逊 Linux AMI AL1 () 的平台分支的状态设置为停用。** 。

本主题指导你将应用程序从在 64 *位 Amazon Linux 上运行的停用平台分支多容器 Docker 迁移到在 64 位* *023 上 AL2运行的 ECS*。此目标平台分支是最新的并且受支持。与之前的*多容器 Docker AL1* 分支一样，较新的 *ECS AL2 023* 平台分支使用 Amazon ECS 在 Elastic Beanstalk 环境中协调将多个 Docker 容器部署到亚马逊 ECS 集群。新的 *ECS AL2 023* 平台分支支持之前的*多容器 Docker AL1* 平台分支中的所有功能。此外，还支持相同的 `Dockerrun.aws.json` v2 文件。

**Topics**
+ [使用 Elastic Beanstalk 控制台来迁移](#migrate-to-ec2-AL2-platform-steps-console)
+ [使用迁移 Amazon CLI](#migrate-to-ec2-AL2-platform-steps-cli)

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

要使用 Elastic Beanstalk 控制台进行迁移，请将相同的源代码部署到基于 *ECS AL2 在 023 平台分支上运行的新环境中*。源代码无需更改。

**迁移到*在 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)。

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

你还可以选择使用 Amazon Command Line Interface (Amazon CLI) 将现有的*多容器 Docker Amazon Linux Docker* 环境迁移到较新的 *ECS AL2 0* 23 平台分支。在这种情况下，您无需创建新环境或重新部署源代码。您只需要运行 Amazon CLI [更新环境](https://docs.amazonaws.cn/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 平台最新解决方案堆栈的列表，请参阅*Amazon Elastic Beanstalk 平台*指南中的[支持平台](https://docs.amazonaws.cn/elasticbeanstalk/latest/platforms/platforms-supported.html#platforms-supported.docker)。

**注意**  
 该[list-available-solution-stacks](https://docs.amazonaws.cn/cli/latest/reference/elasticbeanstalk/list-available-solution-stacks.html)命令提供您的账户在某个 Amazon 区域中可用的平台版本列表。  

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

要了解更多信息 Amazon CLI，请参阅《[https://docs.amazonaws.cn//cli/latest/userguide/cli-chap-welcome.html](https://docs.amazonaws.cn//cli/latest/userguide/cli-chap-welcome.html)。有关 Elastic Beanstalk Amazon CLI 命令的更多信息，[https://docs.amazonaws.cn//cli/latest/reference/elasticbeanstalk/index.html](https://docs.amazonaws.cn//cli/latest/reference/elasticbeanstalk/index.html)。