

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

# CodeBuild 提供的 Docker 映像
<a name="build-env-ref-available"></a>

*支援的影像*是 CodeBuild 中可用影像的最新主要版本，並以次要和修補程式版本更新進行更新。CodeBuild 透過在機器的 [Amazon Machine Image (AMI)](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AMIs.html#ami-using) 中快取支援的影像來最佳化組建的佈建持續時間。如果您想要從快取中獲益，並將建置的佈建持續時間降至最低，請在 CodeBuild 主控台**的映像版本區段中選取永遠使用此執行時間版本的最新****映像**，而非更精細的版本，例如 `aws/codebuild/amazonlinux-x86_64-standard:4.0-1.0.0`。

**Topics**
+ [取得目前 Docker 映像的清單](build-env-ref-available-get.md)
+ [EC2 運算映像](ec2-compute-images.md)
+ [Lambda 運算映像](lambda-compute-images.md)
+ [已取代的 CodeBuild 映像](deprecated-images.md)
+ [可用的執行時間](available-runtimes.md)
+ [執行時間版本](runtime-versions.md)

# 取得目前 Docker 映像的清單
<a name="build-env-ref-available-get"></a>

CodeBuild 會經常更新 Docker 映像清單，以新增最新映像並棄用舊映像。若要取得最新的清單，請執行下列其中一項操作：
+ 在 CodeBuild 主控台的**建立建置專案**精靈或**編輯建置專案**頁面中，針對**環境映像**，選擇**受管映像**。從 **Operating system (作業系統)**、**Runtime (執行時間)** 和 **Runtime version (執行時間版本)** 下拉式清單中，進行選擇。如需詳細資訊，請參閱 [建立組建專案 (主控台)](create-project.md#create-project-console) 或 [變更建置專案的設定 (主控台)](change-project.md#change-project-console) 。
+ 針對 AWS CLI，執行 `list-curated-environment-images`命令：

  ```
  aws codebuild list-curated-environment-images
  ```
+ 對於 AWS SDKs，請呼叫目標程式設計語言的 `ListCuratedEnvironmentImages`操作。如需更多資訊，請參閱[AWS SDKs和工具參考](sdk-ref.md)。

# EC2 運算映像
<a name="ec2-compute-images"></a>

AWS CodeBuild 支援 CodeBuild 中可用於 EC2 運算的下列 Docker 映像。

**注意**  
Windows Server Core 2019 平台的基礎映像僅適用於下列區域：  
美國東部 (維吉尼亞北部)
美國東部 (俄亥俄)
美國西部 (奧勒岡)
歐洲 (愛爾蘭)


| 平台 | 映像識別符 | 定義 | 
| --- | --- | --- | 
| Amazon Linux 2 | aws/codebuild/amazonlinux-x86\$164-standard:4.0 | [al/standard/4.0](https://github.com/aws/aws-codebuild-docker-images/tree/master/al/x86_64/standard/4.0) | 
| Amazon Linux 2023 | aws/codebuild/amazonlinux-x86\$164-standard:5.0 | [al/standard/5.0](https://github.com/aws/aws-codebuild-docker-images/tree/master/al/x86_64/standard/5.0) | 
| Amazon Linux 2023 | aws/codebuild/amazonlinux-x86\$164-standard:6.0 | [al/standard/6.0](https://github.com/aws/aws-codebuild-docker-images/tree/master/al/x86_64/standard/6.0) | 
| Amazon Linux 2 | aws/codebuild/amazonlinux-x86\$164-standard:corretto8 | [al/standard/corretto8](https://github.com/aws/aws-codebuild-docker-images/tree/master/al/x86_64/standard/corretto8) | 
| Amazon Linux 2 | aws/codebuild/amazonlinux-x86\$164-standard:corretto11 | [al/standard/corretto11](https://github.com/aws/aws-codebuild-docker-images/tree/master/al/x86_64/standard/corretto11) | 
| Amazon Linux 2 | aws/codebuild/amazonlinux-aarch64-standard:2.0 | [al/aarch64/standard/2.0](https://github.com/aws/aws-codebuild-docker-images/tree/master/al/aarch64/standard/2.0) | 
| Amazon Linux 2023 | aws/codebuild/amazonlinux-aarch64-standard:3.0 | [al/aarch64/standard/3.0](https://github.com/aws/aws-codebuild-docker-images/tree/master/al/aarch64/standard/3.0) | 
| Ubuntu 20.04 | aws/codebuild/standard:5.0 | [ubuntu/standard/5.0](https://github.com/aws/aws-codebuild-docker-images/tree/master/ubuntu/standard/5.0) | 
| Ubuntu 22.04 | aws/codebuild/standard:6.0 | [ubuntu/standard/6.0](https://github.com/aws/aws-codebuild-docker-images/tree/master/ubuntu/standard/6.0) | 
| Ubuntu 22.04 | aws/codebuild/standard:7.0 | [ubuntu/standard/7.0](https://github.com/aws/aws-codebuild-docker-images/tree/master/ubuntu/standard/7.0) | 
| Ubuntu 24.04 | aws/codebuild/standard:8.0 | [ubuntu/standard/8.0](https://github.com/aws/aws-codebuild-docker-images/tree/master/ubuntu/standard/8.0) | 
| Windows Server Core 2019 | aws/codebuild/windows-base:2019-1.0 | N/A | 
| Windows Server Core 2019 | aws/codebuild/windows-base:2019-2.0 | N/A | 
| Windows Server Core 2019 | aws/codebuild/windows-base:2019-3.0 | N/A | 
| Windows Server Core 2022 | aws/codebuild/windows-base:2022-1.0 | N/A | 

**注意**  
2024 年 11 月 22 日，Linux 型標準執行期映像的別名已從 更新`amazonlinux2`為 `amazonlinux`。不需要手動更新，因為先前的別名仍然有效。

# Lambda 運算映像
<a name="lambda-compute-images"></a>

AWS CodeBuild 支援下列可在 CodeBuild 中 AWS Lambda 運算的 Docker 映像。

**重要**  
使用 Lambda 運算或預留容量時，不支援 `on-failure` 屬性。此屬性僅適用於 CodeBuild 提供的 EC2 運算映像。


**`aarch64` 架構**  

| 平台 | 映像識別符 | 定義 | 
| --- | --- | --- | 
| Amazon Linux 2 | aws/codebuild/amazonlinux-aarch64-lambda-standard:dotnet6 | [al-lambda/aarch64/dotnet6](https://github.com/aws/aws-codebuild-docker-images/tree/master/al-lambda/aarch64/dotnet6) | 
| Amazon Linux 2023 | aws/codebuild/amazonlinux-aarch64-lambda-standard:dotnet8 | [al-lambda/aarch64/dotnet8](https://github.com/aws/aws-codebuild-docker-images/tree/master/al-lambda/aarch64/dotnet8) | 
| Amazon Linux 2 | aws/codebuild/amazonlinux-aarch64-lambda-standard:go1.21 | [al-lambda/aarch64/go1.21](https://github.com/aws/aws-codebuild-docker-images/tree/master/al-lambda/aarch64/go1.21) | 
| Amazon Linux 2023 | aws/codebuild/amazonlinux-aarch64-lambda-standard:go1.24 | [al-lambda/aarch64/go1.24](https://github.com/aws/aws-codebuild-docker-images/tree/master/al-lambda/aarch64/go1.24) | 
| Amazon Linux 2 | aws/codebuild/amazonlinux-aarch64-lambda-standard:corretto11 | [al-lambda/aarch64/corretto11](https://github.com/aws/aws-codebuild-docker-images/tree/master/al-lambda/aarch64/corretto11) | 
| Amazon Linux 2 | aws/codebuild/amazonlinux-aarch64-lambda-standard:corretto17 | [al-lambda/aarch64/corretto17](https://github.com/aws/aws-codebuild-docker-images/tree/master/al-lambda/aarch64/corretto17) | 
| Amazon Linux 2023 | aws/codebuild/amazonlinux-aarch64-lambda-standard:corretto21 | [al-lambda/aarch64/corretto21](https://github.com/aws/aws-codebuild-docker-images/tree/master/al-lambda/aarch64/corretto21) | 
| Amazon Linux 2 | aws/codebuild/amazonlinux-aarch64-lambda-standard:nodejs18 | [al-lambda/aarch64/nodejs18](https://github.com/aws/aws-codebuild-docker-images/tree/master/al-lambda/aarch64/nodejs18) | 
| Amazon Linux 2023 | aws/codebuild/amazonlinux-aarch64-lambda-standard:nodejs20 | [al-lambda/aarch64/nodejs20](https://github.com/aws/aws-codebuild-docker-images/tree/master/al-lambda/aarch64/nodejs20) | 
| Amazon Linux 2023 | aws/codebuild/amazonlinux-aarch64-lambda-standard:nodejs22 | [al-lambda/aarch64/nodejs22](https://github.com/aws/aws-codebuild-docker-images/tree/master/al-lambda/aarch64/nodejs22) | 
| Amazon Linux 2 | aws/codebuild/amazonlinux-aarch64-lambda-standard:python3.11 | [al-lambda/aarch64/python3.11](https://github.com/aws/aws-codebuild-docker-images/tree/master/al-lambda/aarch64/python3.11) | 
| Amazon Linux 2023 | aws/codebuild/amazonlinux-aarch64-lambda-standard:python3.12 | [al-lambda/aarch64/python3.12](https://github.com/aws/aws-codebuild-docker-images/tree/master/al-lambda/aarch64/python3.12) | 
| Amazon Linux 2023 | aws/codebuild/amazonlinux-aarch64-lambda-standard:python3.13 | [al-lambda/aarch64/python3.13](https://github.com/aws/aws-codebuild-docker-images/tree/master/al-lambda/aarch64/python3.13) | 
| Amazon Linux 2 | aws/codebuild/amazonlinux-aarch64-lambda-standard:ruby3.2 | [al-lambda/aarch64/ruby3.2](https://github.com/aws/aws-codebuild-docker-images/tree/master/al-lambda/aarch64/ruby3.2) | 
| Amazon Linux 2023 | aws/codebuild/amazonlinux-aarch64-lambda-standard:ruby3.4 | [al-lambda/aarch64/ruby3.4](https://github.com/aws/aws-codebuild-docker-images/tree/master/al-lambda/aarch64/ruby3.4) | 


**`x86_64` 架構**  

| 平台 | 映像識別符 | 定義 | 
| --- | --- | --- | 
| Amazon Linux 2 | aws/codebuild/amazonlinux-x86\$164-lambda-standard:dotnet6 | [al-lambda/x86\$164/dotnet6](https://github.com/aws/aws-codebuild-docker-images/tree/master/al-lambda/x86_64/dotnet6) | 
| Amazon Linux 2023 | aws/codebuild/amazonlinux-x86\$164-lambda-standard:dotnet8 | [al-lambda/x86\$164/dotnet8](https://github.com/aws/aws-codebuild-docker-images/tree/master/al-lambda/x86_64/dotnet8) | 
| Amazon Linux 2 | aws/codebuild/amazonlinux-x86\$164-lambda-standard:go1.21 | [al-lambda/x86\$164/go1.21](https://github.com/aws/aws-codebuild-docker-images/tree/master/al-lambda/x86_64/go1.21) | 
| Amazon Linux 2023 | aws/codebuild/amazonlinux-x86\$164-lambda-standard:go1.24 | [al-lambda/x86\$164/go1.24](https://github.com/aws/aws-codebuild-docker-images/tree/master/al-lambda/x86_64/go1.24) | 
| Amazon Linux 2 | aws/codebuild/amazonlinux-x86\$164-lambda-standard:corretto11 | [al-lambda/x86\$164/corretto11](https://github.com/aws/aws-codebuild-docker-images/tree/master/al-lambda/x86_64/corretto11) | 
| Amazon Linux 2 | aws/codebuild/amazonlinux-x86\$164-lambda-standard:corretto17 | [al-lambda/x86\$164/corretto17](https://github.com/aws/aws-codebuild-docker-images/tree/master/al-lambda/x86_64/corretto17) | 
| Amazon Linux 2023 | aws/codebuild/amazonlinux-x86\$164-lambda-standard:corretto21 | [al-lambda/x86\$164/corretto21](https://github.com/aws/aws-codebuild-docker-images/tree/master/al-lambda/x86_64/corretto21) | 
| Amazon Linux 2 | aws/codebuild/amazonlinux-x86\$164-lambda-standard:nodejs18 | [al-lambda/x86\$164/nodejs18](https://github.com/aws/aws-codebuild-docker-images/tree/master/al-lambda/x86_64/nodejs18) | 
| Amazon Linux 2023 | aws/codebuild/amazonlinux-x86\$164-lambda-standard:nodejs20 | [al-lambda/x86\$164/nodejs20](https://github.com/aws/aws-codebuild-docker-images/tree/master/al-lambda/x86_64/nodejs20) | 
| Amazon Linux 2023 | aws/codebuild/amazonlinux-x86\$164-lambda-standard:nodejs22 | [al-lambda/x86\$164/nodejs22](https://github.com/aws/aws-codebuild-docker-images/tree/master/al-lambda/x86_64/nodejs22) | 
| Amazon Linux 2 | aws/codebuild/amazonlinux-x86\$164-lambda-standard:python3.11 | [al-lambda/x86\$164/python3.11](https://github.com/aws/aws-codebuild-docker-images/tree/master/al-lambda/x86_64/python3.11) | 
| Amazon Linux 2023 | aws/codebuild/amazonlinux-x86\$164-lambda-standard:python3.12 | [al-lambda/x86\$164/python3.12](https://github.com/aws/aws-codebuild-docker-images/tree/master/al-lambda/x86_64/python3.12) | 
| Amazon Linux 2023 | aws/codebuild/amazonlinux-x86\$164-lambda-standard:python3.13 | [al-lambda/x86\$164/python3.13](https://github.com/aws/aws-codebuild-docker-images/tree/master/al-lambda/x86_64/python3.13) | 
| Amazon Linux 2 | aws/codebuild/amazonlinux-x86\$164-lambda-standard:ruby3.2 | [al-lambda/x86\$164/ruby3.2](https://github.com/aws/aws-codebuild-docker-images/tree/master/al-lambda/x86_64/ruby3.2) | 
| Amazon Linux 2023 | aws/codebuild/amazonlinux-x86\$164-lambda-standard:ruby3.4 | [al-lambda/x86\$164/ruby3.4](https://github.com/aws/aws-codebuild-docker-images/tree/master/al-lambda/x86_64/ruby3.4) | 

# 已取代的 CodeBuild 映像
<a name="deprecated-images"></a>

*已棄用的影像*是 CodeBuild 不再快取或更新的映像。已棄用的影像不會再收到次要版本更新或修補程式版本更新，而且因為它們不再更新，因此使用它們可能不安全。如果您的 CodeBuild 專案設定為使用較舊的映像版本，佈建程序會下載此 docker 映像，並使用它來建立容器化執行期環境，這可能會增加佈建持續時間和整體建置持續時間。

CodeBuild 已棄用下列 Docker 映像。您仍然可以使用這些映像，但這些映像不會快取在建置主機上，而且會導致較高的佈建時間。


| 平台 | 映像識別符 | 定義 | 取代日期 | 
| --- | --- | --- | --- | 
| Amazon Linux 2 | aws/codebuild/amazonlinux2-x86\$164-standard:3.0 | al2/standard/3.0 | 2023 年 5 月 9 日 | 
| Ubuntu 18.04 | aws/codebuild/standard:4.0 | ubuntu/standard/4.0 | 2023 年 3 月 31 日 | 
| Amazon Linux 2 | aws/codebuild/amazonlinux2-aarch64-standard:1.0 | al2/aarch64/standard/1.0 | 2023 年 3 月 31 日 | 
| Ubuntu 18.04 | aws/codebuild/standard:3.0 | ubuntu/standard/3.0 | 2022 年 6 月 30 日 | 
| Amazon Linux 2 | aws/codebuild/amazonlinux2-x86\$164-standard:2.0 | al2/standard/2.0 | 2022 年 6 月 30 日 | 

**Topics**
+ [取得目前 Docker 映像的清單](build-env-ref-available-get.md)
+ [EC2 運算映像](ec2-compute-images.md)
+ [Lambda 運算映像](lambda-compute-images.md)
+ [已取代的 CodeBuild 映像](deprecated-images.md)
+ [可用的執行時間](available-runtimes.md)
+ [執行時間版本](runtime-versions.md)

# 可用的執行時間
<a name="available-runtimes"></a>

您可以在 buildspec 檔案的 `runtime-versions` 區段中指定一或多個執行時間。如果您的執行階段依存於另一個執行時間，您也可以在 buildspec 檔案中指定其相依的執行時間。如果您未在 buildspec 檔案中指定任何執行時間，CodeBuild 會選擇您所使用的映像中可用的預設執行時間。如果您指定一或多個執行時間，CodeBuild 只會使用這些執行時間。如果未指定相依執行時間，CodeBuild 會嘗試為您選擇相依執行時間。

**注意**  
如果未指定執行時間版本，CodeBuild 會使用預設版本。當先前的預設版本達到生命週期結束 (EOL) 時，預設版本可能會變更。為避免意外變更建置環境，建議您在 buildspec 檔案中指定執行時間版本。

 如需詳細資訊，請參閱[Specify runtime versions in the buildspec file](build-spec-ref.md#runtime-versions-buildspec-file)。

[Specify runtime versions in the buildspec file](build-spec-ref.md#runtime-versions-buildspec-file).

.

**Topics**
+ [Linux 映像執行時間](#linux-runtimes)
+ [macOS 映像執行時間](#macOS-runtimes)
+ [Windows 映像執行時間](#windows-runtimes)

## Linux 映像執行時間
<a name="linux-runtimes"></a>

下表包含可用的執行時間，以及支援這些執行時間的標準 Linux 映像。


**Ubuntu 和 Amazon Linux 平台執行時間**  
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/codebuild/latest/userguide/available-runtimes.html)

## macOS 映像執行時間
<a name="macOS-runtimes"></a>

**重要**  
Mac 組建的 CodeBuild 精選映像包含預先安裝的 macOS 和 Xcode。使用 Xcode 軟體，即表示您認可、了解和同意 [Xcode 和 Apple SDKs協議](https://www.apple.com/legal/sla/docs/xcode.pdf)。如果您不接受協議的條款與條件，請勿使用 Xcode 軟體。反之，請提供您自己的 Amazon Machine Image (AMI)。如需詳細資訊，請參閱[如何設定預留容量 macOS 機群？](fleets.md#fleets.configure-macos)

下表包含 macOS 支援的可用執行時間。


**macOS 平台執行時間**  
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/codebuild/latest/userguide/available-runtimes.html)

## Windows 映像執行時間
<a name="windows-runtimes"></a>

Windows Server Core 2019 的基礎映像包含下列執行時間。


**Windows 平台執行時間**  

| 執行時間名稱 | Windows Server Core 2019 標準：1.0 版 | Windows Server Core 2019 標準：2.0 版 | Windows Server Core 2019 標準：3.0 版本 | 
| --- | --- | --- | --- | 
| dotnet | 3.15.0 | 3.16.07.0 | 8.0 | 
| dotnet sdk | 3.15.0 | 3.16.07.0 | 8.0 | 
| golang | 1.14 | 1.18 | 1.211.221.23 | 
| gradle | 6.7 | 7.6 | 8.12 | 
| java | Corretto11 | Corretto11Corretto17 | Corretto8Corretto11Corretto17Corretto21 | 
| maven | 3.6 | 3.8 | 3.9 | 
| nodejs | 14.15 | 16.19 | 20.1822.13 | 
| php | 7.4 | 8.1 | 8.38.4 | 
| powershell | 7.1 | 7.2 | 7.4 | 
| python | 3.8 | 3.10 | 3.103.113.123.13 | 
| ruby | 2.7 | 3.1 | 3.23.33.4 | 

# 執行時間版本
<a name="runtime-versions"></a>

當您在 Buildspec 檔案的 [`runtime-versions`](build-spec-ref.md#build-spec.phases.install.runtime-versions) 區段中指定執行時間時，您可以指定特定版本、特定主要版本和最新次要版本，或最新版本。下表列出可用的執行時間及其指定方法。並非所有執行時間版本都適用於所有映像。自訂映像也不支援執行期版本選擇。如需詳細資訊，請參閱[可用的執行時間](available-runtimes.md)。如果您想要安裝並使用自訂執行時間版本，而非預先安裝的執行時間版本，請參閱 [自訂執行時間版本](#custom-runtime)。


**Ubuntu 和 Amazon Linux 2 平台執行時間版本**  
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/codebuild/latest/userguide/runtime-versions.html)

您可以使用建置規格，在`install`建置階段安裝其他元件 （例如， AWS CLI、Apache Maven、Apache Ant、Mocha、RSpec 等）。如需詳細資訊，請參閱[Buildspec 範例](build-spec-ref.md#build-spec-ref-example)。

## 自訂執行時間版本
<a name="custom-runtime"></a>

您可以安裝和使用您選擇的自訂版本，而不是在 CodeBuild 受管映像中使用預先安裝的執行期版本。下表列出可用的自訂執行期，以及如何指定它們。

**注意**  
只有 Ubuntu 和 Amazon Linux 映像才支援自訂執行時間版本選擇。


**自訂執行時間版本**  

| 執行時間名稱  | 語法 | 範例 | 
| --- | --- | --- | 
| dotnet |  `<major>.<minor>.<patch>`  |  `5.0.408`  | 
| golang |  `<major>.<minor>` `<major>.<minor>.<patch>`  |  `1.19` `1.19.1`  | 
| java |  `corretto<major>`  |  `corretto15`  | 
| nodejs |  `<major>` `<major>.<minor>` `<major>.<minor>.<patch>`  |  `14` `14.21` `14.21.3`  | 
| php |  `<major>.<minor>.<patch>`  |  `8.0.30`  | 
| python |  `<major>` `<major>.<minor>` `<major>.<minor>.<patch>`  |  `3` `3.7` `3.7.16`  | 
| ruby |  `<major>.<minor>.<patch>`  |  `3.0.6`  | 

### 自訂執行期 buildspec 範例
<a name="custom-runtime-buildspec"></a>

以下是指定自訂執行時間版本的 buildspec 範例。

```
version: 0.2
phases:
  install:
    runtime-versions:
      java: corretto15
      php: 8.0.30
      ruby: 3.0.6
      golang: 1.19
      python: 3.7
      nodejs: 14
      dotnet: 5.0.408
```