

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

# 的图像存储库 AWS SAM
<a name="serverless-image-repositories"></a>

AWS SAM 借助构建容器映像，简化无服务器应用程序的持续集成和持续交付 (CI/CD) 任务。 AWS SAM 提供的镜像包括许多支持的 AWS Lambda 运行时的 AWS SAM 命令行界面 (CLI) 和构建工具。这使得使用 AWS SAM CLI 构建和打包无服务器应用程序变得更轻松。您可以将这些映像与 CI/CD 系统配合使用，以自动构建和部署 AWS SAM 应用程序。有关示例，请参阅 [使用 CI/CD 系统和管道进行部署](deploying-options.md#serverless-deploying-ci-cd)。

AWS SAM 构建容器镜像标 URIs 有该镜像中 AWS SAMCLI包含的版本。如果您指定未标记的 URI，则使用最新版本。例如，`public.ecr.aws/sam/build-nodejs20.x` 使用最新的映像。但是，`public.ecr.aws/sam/build-nodejs20.x:1.24.1` 使用包含 AWS SAM CLI 版本 1.24.1 的映像。

从版本的 1.33.0 开始 AWS SAMCLI，这两个镜像`x86_64`和`arm64`容器映像都可用于支持的运行时。有关更多信息，请参阅*《AWS Lambda 开发人员指南》*中的 [Lambda 运行时系统](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html)。

**注意**  
在 1.22.0 版本之前 AWS SAMCLI， DockerHub 是从中 AWS SAMCLI提取容器映像的默认存储库。从版本 1.22.0 开始，默认存储库改为 Amazon Elastic Container Public (Amazon ECR Public)。要从当前默认存储库以外的存储库中提取容器映像，可以使用带 **--build-image** 选项的 **[sam build](sam-cli-command-reference-sam-build.md)** 命令。本主题末尾的示例展示了如何使用 DockerHub 存储库映像构建应用程序。

## 镜像存储库 URIs
<a name="serverless-image-repository-uris"></a>

下表列出了可用于构建和打包无服务器应用程序的 [Amazon ECR 公共](https://docs.aws.amazon.com/AmazonECR/latest/public/what-is-ecr.html)版本容器映像。 URIs AWS SAM

**注意**  
从 AWS SAM CLI 版本 1.22.0 开始，Amazon ECR Public 取代了 DockerHub。如果您使用的是的早期版本 AWS SAMCLI，我们建议您升级。


| 运行时 |  Amazon ECR Public | 
| --- | --- | 
| 自定义运行时 (AL2023) | [public.ecr。 aws/sam/build-提供](https://gallery.ecr.aws/sam/build-provided.al2023)。al2023 | 
| 自定义运行时 (AL2) | [public.ecr。 aws/sam/build-提供的.al2](https://gallery.ecr.aws/sam/build-provided.al2) | 
| 自定义运行时 | [public.ecr。 aws/sam/build](https://gallery.ecr.aws/sam/build-provided)-已提供 | 
| Java 25 | [public.ecr。 aws/sam/build-java25](https://gallery.ecr.aws/sam/build-java25) | 
| Java 21 | [public.ecr。 aws/sam/build-java21](https://gallery.ecr.aws/sam/build-java21) | 
| Java 17 | [public.ecr。 aws/sam/build-java17](https://gallery.ecr.aws/sam/build-java17) | 
| Java 11 | [public.ecr。 aws/sam/build-java11](https://gallery.ecr.aws/sam/build-java11) | 
| Java 8 | [public.ecr。 aws/sam/build-java8](https://gallery.ecr.aws/sam/build-java8) | 
| .NET 9 | [public.ecr。 aws/sam/build-dotnet9](https://gallery.ecr.aws/sam/build-dotnet9) | 
| .NET 8 | [public.ecr。 aws/sam/build-dotnet8](https://gallery.ecr.aws/sam/build-dotnet8) | 
| .NET 7 | [public.ecr。 aws/sam/build-dotnet7](https://gallery.ecr.aws/sam/build-dotnet7) | 
| .NET 6 | [public.ecr。 aws/sam/build-dotnet6](https://gallery.ecr.aws/sam/build-dotnet6) | 
| Node.js 24 | [public.ecr。 aws/sam/build-nodejs24.x](https://gallery.ecr.aws/sam/build-nodejs24.x) | 
| Node.js 22 | [public.ecr。 aws/sam/build-nodejs22.x](https://gallery.ecr.aws/sam/build-nodejs22.x) | 
| Node.js 20 | [public.ecr。 aws/sam/build-nodejs20.x](https://gallery.ecr.aws/sam/build-nodejs20.x) | 
| Node.js 18 | [public.ecr。 aws/sam/build-nodejs18.x](https://gallery.ecr.aws/sam/build-nodejs18.x) | 
| Node.js 16 | [public.ecr。 aws/sam/build-nodejs16.x](https://gallery.ecr.aws/sam/build-nodejs16.x) | 
| Python 3.14 | [public.ecr。 aws/sam/build-py](https://gallery.ecr.aws/sam/build-python3.14) thon 3.14 | 
| Python 3.13 | [public.ecr。 aws/sam/build-py](https://gallery.ecr.aws/sam/build-python3.13) thon3.13 | 
| Python 3.12 | [public.ecr。 aws/sam/build-py](https://gallery.ecr.aws/sam/build-python3.12) thon 3.12 | 
| Python 3.11 | [public.ecr。 aws/sam/build-py](https://gallery.ecr.aws/sam/build-python3.11) thon 3.11 | 
| Python 3.10 | [public.ecr。 aws/sam/build-py](https://gallery.ecr.aws/sam/build-python3.10) thon 3.10 | 
| Python 3.9 | [public.ecr。 aws/sam/build-py](https://gallery.ecr.aws/sam/build-python3.9) thon 3.9 | 
| Python 3.8 | [public.ecr。 aws/sam/build-py](https://gallery.ecr.aws/sam/build-python3.8) thon3.8 | 
| Ruby 3.4 | [public.ecr。 aws/sam/build-ruby3.4](https://gallery.ecr.aws/sam/build-ruby3.4) | 
| Ruby 3.3 | [public.ecr。 aws/sam/build-ruby3.3](https://gallery.ecr.aws/sam/build-ruby3.3) | 
| Ruby 3.2 | [public.ecr。 aws/sam/build-ruby3.2](https://gallery.ecr.aws/sam/build-ruby3.2) | 

## 示例
<a name="serverless-image-repository-example-commands"></a>

以下两个示例命令使用映像存储库中的容器映像构建应用程序：

**使用从 Amazon ECR 提取的容器映像构建 Node.js 24 应用程序**：

```
$ sam build --use-container --build-image public.ecr.aws/sam/build-nodejs24.x
```

**使用从 Amazon ECR 提取的 Python 3.14 容器映像构建函数资源**：

```
$ sam build --use-container --build-image Function1=public.ecr.aws/sam/build-python3.14
```