

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

# Amazon ECS 已停止任務錯誤訊息
<a name="stopped-task-error-codes"></a>

以下是任務意外停止時，可能會收到的錯誤訊息。

若要使用 檢查已停止的任務是否有錯誤訊息 AWS 管理主控台，請參閱 [檢視 Amazon ECS 已停止任務錯誤](stopped-task-errors.md)。

**提示**  
您可以[Amazon ECS MCP 伺服器](ecs-mcp-introduction.md)搭配 AI 助理使用 ，以自然語言分析任務失敗和容器日誌。

已停止任務錯誤代碼具有與其相關聯的類別，例如 "ResourceInitializationError"。如需了解每個類別的詳細資訊，請參閱下列主題：


| Category | 進一步了解 | 
| --- | --- | 
|  TaskFailedToStart  |  [對 Amazon ECS TaskFailedToStart 錯誤進行疑難排解](failed-to-start-error.md)  | 
|  ResourceInitializationError  |  [對 Amazon ECS ResourceInitializationError 錯誤進行疑難排解](resource-initialization-error.md)  | 
| ResourceNotFoundException |  [對 Amazon ECS ResourceNotFoundException 錯誤進行疑難排解](resource-not-found-error.md) | 
|  SpotInterruptionError  |  [對 Amazon ECS SpotInterruption 錯誤進行疑難排解](spot-interruption-errors.md)  | 
|  InternalError  |  [對 Amazon ECS InternalError 錯誤進行疑難排解](internal-error.md)  | 
|  OutOfMemoryError  |  [對 Amazon ECS OutOfMemoryError 錯誤進行疑難排解](out-of-memory.md)  | 
|  ContainerRuntimeError  |  [對 Amazon ECS ContainerRuntimeError 錯誤進行疑難排解](container-runtime-error.md)  | 
|  ContainerRuntimeTimeoutError  |  [對 Amazon ECS ContainerRuntimeTimeoutError 錯誤進行疑難排解](container-runtime-timeout-error.md)  | 
|  CannotStartContainerError  |  [對 Amazon ECS CannotStartContainerError 錯誤進行疑難排解](cannot-start-container.md)  | 
|  CannotStopContainerError  |  [對 Amazon ECS CannotStopContainerError 錯誤進行疑難排解](cannot-stop-container.md)  | 
|  CannotInspectContainerError  |  [對 Amazon ECS CannotInspectContainerError 錯誤進行疑難排解](cannot-inspect-container.md)  | 
|  CannotCreateVolumeError  |  [對 Amazon ECS CannotCreateVolumeError 錯誤進行疑難排解](cannot-create-volume.md)  | 
| CannotPullContainer |  [Amazon ECS 中的 CannotPullContainer 任務錯誤](task_cannot_pull_image.md)  | 

# 對 Amazon ECS TaskFailedToStart 錯誤進行疑難排解
<a name="failed-to-start-error"></a>

以下是部分 `TaskFailedToStart` 錯誤訊息以及可採取的錯誤修正動作。

若要使用 檢查已停止的任務是否有錯誤訊息 AWS 管理主控台，請參閱 [檢視 Amazon ECS 已停止任務錯誤](stopped-task-errors.md)。

## 嘗試在子網路 *subnet-id* 中建立啟用了公有 IP 指派的網路介面時，發生意外 EC2 錯誤
<a name="subnet-error"></a>

當 Fargate 任務使用 `awsvpc` 網路模式並在具有公有 IP 位址的子網路中執行，且子網路沒有足夠的 IP 位址時，就會發生這種情況。

可在 Amazon EC2 主控台的子網路詳細資訊頁面上檢視可用 IP 位址的數量，也可透過 `[describe-subnets](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-subnets.html)` 檢視該數量。如需詳細資訊，請參閱 *Amazon VPC User Guide* 中的 [View your subnet](https://docs.aws.amazon.com/vpc/latest/userguide/working-with-vpcs.html#view-subnet)。

若要修正此問題，您可以建立新的子網路，在其中執行任務。

## InternalError: *<reason>*
<a name="internal-error-reason"></a>

在請求 ENI 附件時，會發生此錯誤。Amazon EC2 以非同步方式處理 ENI 的佈建。佈建程序需要時間。Amazon ECS 會出現逾時，導致等待時間較長或未報告的故障。有時會佈建 ENI，但報告會在故障逾時後傳送給 Amazon ECS。在這種情況下，Amazon ECS 會透過使用中的 ENI 查看報告的任務失敗。

## 選取的任務定義與選取的運算策略不相容
<a name="compute-compatibility"></a>

當您選擇啟動類型不符合叢集容量類型的任務定義時，就會發生此錯誤。您需要選取與指派給叢集的容量提供者相符的任務定義。

## 無法將網路介面連接至閒置的裝置索引
<a name="compute-compatibility-cpu"></a>

使用 `awsvpc` 聯網類型且任務沒有足夠的 CPU/記憶體時，即會發生此錯誤。首先，檢查執行個體的 CPU。如需詳細資訊，請參閱 *Amazon EC2 instance types* 中的 [Amazon EC2 instance type specifications](https://docs.aws.amazon.com/ec2/latest/instancetypes/ec2-instance-type-specifications.html) 。取執行個體的 CPU 值，並將其乘以執行個體 ENI 數量。在任務定義中使用值 e。

## 代理程式
<a name="agent-not-started"></a>

您嘗試啟動任務所在之容器執行個體上的代理程式目前中斷連線。為避免延長任務置放等待時間，請求遭到拒絕。

如需如何對已中斷連線的代理程式進行故障診斷的相關資訊，請參閱 [How do I troubleshoot a disconnected Amazon ECS agent](https://repost.aws/knowledge-center/ecs-agent-disconnected-linux2-ami) (如何對已中斷連線的 Amazon ECS 代理程式進行故障診斷)。

# 對 Amazon ECS ResourceInitializationError 錯誤進行疑難排解
<a name="resource-initialization-error"></a>

以下是部分 `ResourceInitialization` 錯誤訊息以及可採取的錯誤修正動作。

若要使用 檢查已停止的任務是否有錯誤訊息 AWS 管理主控台，請參閱 [檢視 Amazon ECS 已停止任務錯誤](stopped-task-errors.md)。

**Topics**
+ [The task cannot pull registry authentication from Amazon ECR. There is a connection issue between the task and Amazon ECR. Check your task network configuration.](#unable-to-pull-secrets-ecr)
+ [The task can't download the environment variable files from Amazon S3. There is a connection issue between the task and Amazon S3. Check your task network configuration.](#failed-to-download-env-files)
+ [任務無法從 AWS Systems Manager 參數存放區提取秘密。檢查任務與 之間的網路連線 AWS Systems Manager。](#unable-to-pull-secrets-sys-manager)
+ [任務無法從中提取秘密 AWS Secrets Manager。There is a connection issue between the task and Secrets Manager. Check your task network configuration.](#unable-to-pull-secrets-asm-no-arn)
+ [The task can’t pull the secret from Secrets Manager. The task can't retrieve the secret with ARN ‘*secretARN*' from Secrets Manager. Check whether the secret exists in the specified Region.](#unable-to-pull-secrets-asm)
+ [pull command failed: unable to pull secrets or registry auth Check your task network configuration.](#pull-command-failed)
+ [任務找不到任務定義中所定義的 Amazon CloudWatch 日誌群組。There is a connection issue between the task and Amazon CloudWatch. Check your network configuration.](#failed-to-initialize-logging-network)
+ [failed to initialize logging driver](#failed-to-initialize-logging)
+ [無法調用 EFS utils 命令來設定 EFS 磁碟區](#efs-utils-failed)

## The task cannot pull registry authentication from Amazon ECR. There is a connection issue between the task and Amazon ECR. Check your task network configuration.
<a name="unable-to-pull-secrets-ecr"></a>

此錯誤表示任務無法連線至 Amazon ECR。

檢查任務與 Amazon ECR 之間的連線。如需相關資訊，請參閱[驗證 Amazon ECS 已停止任務的連線狀態](verify-connectivity.md)。

## The task can't download the environment variable files from Amazon S3. There is a connection issue between the task and Amazon S3. Check your task network configuration.
<a name="failed-to-download-env-files"></a>

當任務無法從 Amazon S3 下載環境檔案時，就會發生此錯誤。

檢查任務與 Amazon S3 VPC 端點之間的連線。如需相關資訊，請參閱[驗證 Amazon ECS 已停止任務的連線狀態](verify-connectivity.md)。

## 任務無法從 AWS Systems Manager 參數存放區提取秘密。檢查任務與 之間的網路連線 AWS Systems Manager。
<a name="unable-to-pull-secrets-sys-manager"></a>

當任務無法使用 Systems Manager 中的憑證提取任務定義中定義的映像時，就會發生此錯誤。

檢查任務與 Systems Manager VPC 端點之間的連線。如需相關資訊，請參閱[驗證 Amazon ECS 已停止任務的連線狀態](verify-connectivity.md)。

## 任務無法從中提取秘密 AWS Secrets Manager。There is a connection issue between the task and Secrets Manager. Check your task network configuration.
<a name="unable-to-pull-secrets-asm-no-arn"></a>

當任務無法使用 Secrets Manager 中的憑證提取任務定義中定義的映像時，就會發生此錯誤。

此錯誤表示 Systems Manager VPC 端點與任務之間存在網路連線問題。

如需有關如何驗證任務與端點之間連線的資訊，請參閱[驗證 Amazon ECS 已停止任務的連線狀態](verify-connectivity.md)。

## The task can’t pull the secret from Secrets Manager. The task can't retrieve the secret with ARN ‘*secretARN*' from Secrets Manager. Check whether the secret exists in the specified Region.
<a name="unable-to-pull-secrets-asm"></a>

當任務無法使用 Secrets Manager 中的憑證提取任務定義中定義的映像時，就會發生此錯誤。

此問題由以下其中一個原因造成：


| 錯誤原因... | 執行此作業... | 
| --- | --- | 
|   Secrets Manager VPC 端點與任務之間存在網路連線問題。 在錯誤訊息中看到下列任何字串時，表示存在網路問題： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/AmazonECS/latest/developerguide/resource-initialization-error.html)  |  驗證任務與 Secrets Manager 端點之間的連線狀態。如需詳細資訊，請參閱[驗證 Amazon ECS 已停止任務的連線狀態](verify-connectivity.md)。  | 
| 任務定義中所定義的任務執行角色，沒有 Secrets Manager 所需的許可。 |  將 Secrets Manager 所需的許可新增至任務執行角色。如需詳細資訊，請參閱[Secrets Manager 或 Systems Manager 許可](task_execution_IAM_role.md#task-execution-secrets)。  | 
| 秘密 ARN 不存在 | 檢查 Secrets Manager 中是否存在 ARN。如需有關檢視映像的資訊，請參閱 Secrets Manager Developer Guide 中的 [Find secrets in Secrets Manager](https://docs.aws.amazon.com/secretsmanager/latest/userguide/manage_search-secret.html)。 | 

## pull command failed: unable to pull secrets or registry auth Check your task network configuration.
<a name="pull-command-failed"></a>

當任務無法連線至 Amazon ECR、Systems Manager 或 Secrets Manager 時，就會發生此錯誤。此問題源自於網路組態錯誤。

若要修正此問題，請驗證任務與 Amazon ECR 之間的連線狀態。您也需要檢查任務與儲存秘密的服務 (Systems Manager 或 Secrets Manager) 之間的連線狀態。如需詳細資訊，請參閱[驗證 Amazon ECS 已停止任務的連線狀態](verify-connectivity.md)。

## 任務找不到任務定義中所定義的 Amazon CloudWatch 日誌群組。There is a connection issue between the task and Amazon CloudWatch. Check your network configuration.
<a name="failed-to-initialize-logging-network"></a>

當任務找不到您在任務定義中定義的 CloudWatch 日誌群組時，就會發生此錯誤。

此錯誤表示 CloudWatch VPC 端點與任務之間存在網路連線問題。

如需有關如何驗證任務與端點之間連線的資訊，請參閱[驗證 Amazon ECS 已停止任務的連線狀態](verify-connectivity.md)。

## failed to initialize logging driver
<a name="failed-to-initialize-logging"></a>

當任務找不到您在任務定義中定義的 CloudWatch 日誌群組時，就會發生此錯誤。

此錯誤表示任務定義中的 CloudWatch 群組不存在。

使用下列步驟尋找缺少的 CloudWatch。

1. 執行下列命令來取得任務定義資訊。

   ```
   aws ecs describe-task-definition \ 
       --task-definition task-def-name
   ```

   查看每個容器的輸出，並記下 `awslogs-group` 值。

   ```
   "logConfiguration": {
                   "logDriver": "awslogs",
                   "options": {
                       "awslogs-group": "/ecs/example-group",
                       "awslogs-create-group": "true",
                       "awslogs-region": "us-east-1",
                       "awslogs-stream-prefix": "ecs"
                   },
   ```

1. 確認群組存在於 CloudWatch 中。如需詳細資訊，請參閱 *Amazon CloudWatch Logs User Guide* 中的 [Working with log groups and log streams](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/Working-with-log-groups-and-streams.html)。

   問題可能是任務定義中指定的群組不正確，也可能是日誌群組不存在。

1. 修正問題。    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/AmazonECS/latest/developerguide/resource-initialization-error.html)

## 無法調用 EFS utils 命令來設定 EFS 磁碟區
<a name="efs-utils-failed"></a>

下列問題可能會阻止您在任務上掛載 Amazon EFS 磁碟區：
+ Amazon EFS 檔案系統設定不正確。
+ 任務缺少必要許可。
+ 存在與網路與 VPC 組態相關的問題。

 如需有關如何偵錯和修正此問題的資訊，請參閱[為何我無法在 re：Post 上的 AWS Fargate 任務上掛載 Amazon EFS 磁碟區](https://repost.aws/knowledge-center/fargate-unable-to-mount-efs)。 AWS 

# 對 Amazon ECS ResourceNotFoundException 錯誤進行疑難排解
<a name="resource-not-found-error"></a>

以下是部分 ` ResourceNotFoundException` 錯誤訊息以及可採取的錯誤修正動作。

若要使用 檢查已停止的任務是否有錯誤訊息 AWS 管理主控台，請參閱 [檢視 Amazon ECS 已停止任務錯誤](stopped-task-errors.md)。

## 任務無法從中擷取具有 ARN '*sercretARN*' 的秘密 AWS Secrets Manager。Check whether the secret exists in the specified Region.
<a name="unable-to-pull-secrets-ecr"></a>

當任務無法從 Secrets Manager 擷取秘密時，就會發生此錯誤。這表示在任務定義中指定 (並且在錯誤訊息中包含) 的秘密不存在於 Secrets Manager 中。

區域資訊包含在錯誤訊息中。

從 AWS Secrets Manager *區域*擷取秘密資料：秘密 *sercretARN*：ResourceNotFoundException：Secrets Manager 找不到指定的秘密。

如需有關尋找秘密的資訊，請參閱 *AWS Secrets Manager User Guide* 中的 [Find secrets in AWS Secrets Manager](https://docs.aws.amazon.com/secretsmanager/latest/userguide/manage_search-secret.html)。

使用下表來判斷並解決錯誤。


| 問題 | 動作 | 
| --- | --- | 
| 秘密位於與任務定義不同的區域。 |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/AmazonECS/latest/developerguide/resource-not-found-error.html) | 
| 任務定義的秘密 ARN 不正確。Secrets Manager 中存在正確的秘密。 | 使用正確的秘密更新任務定義。如需詳細資訊，請參閱[使用主控台更新 Amazon ECS 任務定義](update-task-definition-console-v2.md)，或 Amazon Elastic Container Service API Reference 中的 [RegisterTaskDefinition](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_RegisterTaskDefinition.html)。 | 
| 秘密不再存在。 |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/AmazonECS/latest/developerguide/resource-not-found-error.html)  | 

# 對 Amazon ECS SpotInterruption 錯誤進行疑難排解
<a name="spot-interruption-errors"></a>

`SpotInterruption` 錯誤在 Fargate 和 EC2 中發生的原因不相同。

若要使用 檢查已停止的任務是否有錯誤訊息 AWS 管理主控台，請參閱 [檢視 Amazon ECS 已停止任務錯誤](stopped-task-errors.md)。

## Fargate
<a name="fargate-spot-error"></a>

當沒有 Fargate Spot 容量或當 Fargate 取回 Spot 容量時，就會發生 `SpotInterruption` 錯誤。

您可以讓任務在多個可用區域中執行，以取得更多容量。

## EC2
<a name="ec2-spot-error"></a>

當沒有可用的 Spot 執行個體或當 EC2 取回 Spot 執行個體容量時，就會發生此錯誤。

您可以讓執行個體在多個可用區域中執行，以取得更多容量。

# 對 Amazon ECS InternalError 錯誤進行疑難排解
<a name="internal-error"></a>

**適用對象**：Fargate

若要使用 檢查已停止的任務是否有錯誤訊息 AWS 管理主控台，請參閱 [檢視 Amazon ECS 已停止任務錯誤](stopped-task-errors.md)。

當代理程式遇到非執行時期相關的意外內部錯誤時，就會發生 `InternalError` 錯誤。

只有在使用平台版本 `1.4` 或更新版本時，才會發生此錯誤。

如需有關偵錯和修正此問題的資訊，請參閱 [Amazon ECS 已停止任務錯誤訊息](stopped-task-error-codes.md)。

# 對 Amazon ECS OutOfMemoryError 錯誤進行疑難排解
<a name="out-of-memory"></a>

以下是部分 OutOfMemoryError 錯誤訊息以及可採取的錯誤修正動作。

若要使用 檢查已停止的任務是否有錯誤訊息 AWS 管理主控台，請參閱 [檢視 Amazon ECS 已停止任務錯誤](stopped-task-errors.md)。

## container killed due to memory usage
<a name="container-memory-usage"></a>

當容器結束是由於容器中的程序消耗的記憶體比任務定義中分配的記憶體更多時，或是由於主機或作業系統限制時，就會發生此錯誤。

# 對 Amazon ECS ContainerRuntimeError 錯誤進行疑難排解
<a name="container-runtime-error"></a>

以下是部分 ContainerRuntimeError 錯誤訊息以及可採取的錯誤修正動作。

若要使用 檢查已停止的任務是否有錯誤訊息 AWS 管理主控台，請參閱 [檢視 Amazon ECS 已停止任務錯誤](stopped-task-errors.md)。

## ContainerRuntimeError
<a name="container-runtime-error-1"></a>

當代理程式從 `containerd` 接收到特定執行時間操作的意外錯誤時，會發生此錯誤。此錯誤通常是由代理程式或 `containerd` 執行時間的內部失敗所造成。

只有在使用平台版本 `1.4.0` 或更新版本 (Linux)，或 `1.0.0` 或更新版本 (Windows) 時，才會發生此錯誤。

如需有關如何偵錯和修正此問題的資訊，請參閱[為什麼我的 Amazon ECS 任務在 re：Post 上停止](https://repost.aws/knowledge-center/ecs-task-stopped)。 AWS 

# 對 Amazon ECS ContainerRuntimeTimeoutError 錯誤進行疑難排解
<a name="container-runtime-timeout-error"></a>

以下是部分 ContainerRuntimeTimeoutError 錯誤訊息以及可採取的錯誤修正動作。

若要使用 檢查已停止的任務是否有錯誤訊息 AWS 管理主控台，請參閱 [檢視 Amazon ECS 已停止任務錯誤](stopped-task-errors.md)。

## Could not transition to running; timed out after waiting 1m or Docker timeout error
<a name="container-runtime-timeout-error-1"></a>

當容器在逾時期間無法轉換成 `RUNNING` 或 `STOPPED` 狀態時，會發生此錯誤。錯誤訊息中會提供原因和逾時值。

# 對 Amazon ECS CannotStartContainerError 錯誤進行疑難排解
<a name="cannot-start-container"></a>

以下是部分 CannotStartContainerError 錯誤訊息以及可採取的錯誤修正動作。

若要使用 檢查已停止的任務是否有錯誤訊息 AWS 管理主控台，請參閱 [檢視 Amazon ECS 已停止任務錯誤](stopped-task-errors.md)。

## failed to get container status: *<reason>*
<a name="cannot-start-container-1"></a>

無法啟動容器時，會發生此錯誤。

如果容器嘗試使用超過此處指定的記憶體，容器便會終止。增加分配給容器的記憶體。這是任務定義中的 `memory` 參數。如需詳細資訊，請參閱[記憶體](task_definition_parameters.md#container_definition_memory)。

# 對 Amazon ECS CannotStopContainerError 錯誤進行疑難排解
<a name="cannot-stop-container"></a>

以下是部分 CannotStopContainerError 錯誤訊息以及可採取的錯誤修正動作。

若要使用 檢查已停止的任務是否有錯誤訊息 AWS 管理主控台，請參閱 [檢視 Amazon ECS 已停止任務錯誤](stopped-task-errors.md)。

## CannotStopContainerError
<a name="cannot-stop-container-1"></a>

無法停用容器時，會發生此錯誤。

如需有關如何偵錯和修正此問題的資訊，請參閱[為什麼我的 Amazon ECS 任務在 re：Post 上停止](https://repost.aws/knowledge-center/ecs-task-stopped)。 AWS 

# 對 Amazon ECS CannotInspectContainerError 錯誤進行疑難排解
<a name="cannot-inspect-container"></a>

以下是部分 CannotInspectContainerError 錯誤訊息以及可採取的錯誤修正動作。

若要使用 檢查已停止的任務是否有錯誤訊息 AWS 管理主控台，請參閱 [檢視 Amazon ECS 已停止任務錯誤](stopped-task-errors.md)。

## CannotInspectContainerError
<a name="cannot-inspect-container-1"></a>

當容器代理程式無法透過容器執行時間描述容器時，會發生此錯誤。

使用平台版本 `1.3` 或先前版本時，Amazon ECS 代理程式會從 Docker 傳回原因。

使用平台版本 `1.4.0` 或更新版本 (Linux)，或者 `1.0.0` 或更新版本 (Windows) 時，Fargate 代理程式會從 `containerd` 傳回原因。

如需有關如何偵錯和修正此問題的資訊，請參閱[為什麼我的 Amazon ECS 任務在 re：Post 上停止](https://repost.aws/knowledge-center/ecs-task-stopped)。 AWS 

# 對 Amazon ECS CannotCreateVolumeError 錯誤進行疑難排解
<a name="cannot-create-volume"></a>

以下是部分 CannotCreateVolumeError 錯誤訊息以及可採取的錯誤修正動作。

若要使用 檢查已停止的任務是否有錯誤訊息 AWS 管理主控台，請參閱 [檢視 Amazon ECS 已停止任務錯誤](stopped-task-errors.md)。

## CannotCreateVolumeError
<a name="cannot-create-volume-1"></a>

當代理程式無法建立任務定義中指定的磁碟區掛載時，會發生此錯誤。

只有在使用平台版本 `1.4.0` 或更新版本 (Linux)，或 `1.0.0` 或更新版本 (Windows) 時，才會發生此錯誤。

如需有關如何偵錯和修正此問題的資訊，請參閱[為什麼我的 Amazon ECS 任務在 re：Post 上停止](https://repost.aws/knowledge-center/ecs-task-stopped)。 AWS 

# Amazon ECS 中的 CannotPullContainer 任務錯誤
<a name="task_cannot_pull_image"></a>

下列錯誤表示任務無法啟動，因為 Amazon ECS 無法擷取指定的容器映像。

**注意**  
1.4 Fargate 平台版本會截斷長的錯誤訊息。

若要使用 檢查已停止的任務是否有錯誤訊息 AWS 管理主控台，請參閱 [檢視 Amazon ECS 已停止任務錯誤](stopped-task-errors.md)。

**提示**  
您可以[Amazon ECS MCP 伺服器](ecs-mcp-introduction.md)搭配 AI 助理使用 ，使用自然語言調查影像提取錯誤。

**Topics**
+ [The task can’t pull the image. Check that the role has the permissions to pull images from the registry.](#pull-request-image-not-found)
+ [The task cannot pull ‘*image-name*’ from the Amazon ECR repository ‘*repository URI*’. There is a connection issue between the task and Amazon ECR. Check your task network configuration.](#pull-image-io-timeout)
+ [The task can’t pull the image. Check your network configuration](#pull-request-image-not-found-network)
+ [CannotPullContainerError: pull image manifest has been retried 5 time(s): failed to resolve ref](#pull-request-image-tag)
+ [API error (500): Get https://111122223333.dkr.ecr.us-east-1.amazonaws.com/v2/: net/http: request canceled while waiting for connection](#request-canceled)
+ [API 錯誤](#pull-request-api-error)
+ [write /var/lib/docker/tmp/*GetImageBlob111111111*: no space left on device](#pull-request-write-error)
+ [ERROR: toomanyrequests: Too Many Requests or You have reached your pull rate limit.](#container-pull-too-many-requests)
+ [Error response from daemon: Get *url*: net/http: request canceled while waiting for connection](#container-pull-request-canceled-connection)
+ [ref pull has been retried 1 time(s): failed to copy: httpReaderSeeker: failed open: unexpected status code](#container-pull-failed-open)
+ [pull access denied](#container-pull-access-denied.title)
+ [pull command failed: panic: runtime error: invalid memory address or nil pointer dereference](#container-pull-runtime-error.title)
+ [error pulling image conf/error pulling image configuration](#container-pull-pulling-image.title)
+ [內容已取消](#container-pull-context-canceled)

## The task can’t pull the image. Check that the role has the permissions to pull images from the registry.
<a name="pull-request-image-not-found"></a>

此錯誤表示由於許可問題，任務無法提取任務定義中指定的映像。

若要解決此問題：

1. 檢查映像是否存在於*儲存庫*中。如需有關檢視映像的資訊，請參閱 *Amazon Elastic Container Registry User Guide* 中的 [Viewing image details in Amazon ECR](https://docs.aws.amazon.com/AmazonECR/latest/userguide/image-info.html)。

1. 確認 *role-arn* 具有提取映像的正確許可。

   如需有關如何更新角色的資訊，請參閱 *AWS Identity and Access Management Use Guide* 中的 [Update permissions for a role](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_update-role-permissions.html)。

   任務使用以下任一角色：
   + 對於使用 Fargate 的任務，此為任務執行角色。如需有關 Amazon ECR 額外許可的資訊，請參閱 [Fargate 任務透過介面端點提取 Amazon ECR 映像的許可](task_execution_IAM_role.md#task-execution-ecr-conditionkeys)。
   + 對於使用 EC2 的任務，此為容器執行個體角色。如需有關 Amazon ECR 額外許可的資訊，請參閱 [Amazon ECR 許可](instance_IAM_role.md#container-instance-role-ecr)。

## The task cannot pull ‘*image-name*’ from the Amazon ECR repository ‘*repository URI*’. There is a connection issue between the task and Amazon ECR. Check your task network configuration.
<a name="pull-image-io-timeout"></a>

此錯誤表示任務無法連線至 Amazon ECR。檢查*儲存庫 URI* 儲存庫的連線。

如需有關如何確認與解決此問題的資訊，請參閱[驗證 Amazon ECS 已停止任務的連線狀態](verify-connectivity.md)。

## The task can’t pull the image. Check your network configuration
<a name="pull-request-image-not-found-network"></a>

此錯誤表示任務無法連線至 Amazon ECR。

如需有關如何確認與解決此問題的資訊，請參閱[驗證 Amazon ECS 已停止任務的連線狀態](verify-connectivity.md)。

## CannotPullContainerError: pull image manifest has been retried 5 time(s): failed to resolve ref
<a name="pull-request-image-tag"></a>

此錯誤表示任務無法提取映像。

若要解決此問題，您可以：
+ 確認任務定義中指定的映像符合儲存庫中的映像。
+ Amazon ECS 會強制保障映像版本穩定性。若原始映像不再可用，您就會遇到此錯誤。映像標籤是強制實施此項機制的關鍵組成。請將任務定義中的映像標籤從 :latest 更改為特定版本。如需詳細資訊，請參閱[容器映像解析](deployment-type-ecs.md#deployment-container-image-stability)。

如需有關如何確認與解決此問題的資訊，請參閱[驗證 Amazon ECS 已停止任務的連線狀態](verify-connectivity.md)。

## API error (500): Get https://111122223333.dkr.ecr.us-east-1.amazonaws.com/v2/: net/http: request canceled while waiting for connection
<a name="request-canceled"></a>

此錯誤表示連線已逾時，原因是不存在通往網際網路的路由。

要解決此問題，則可以採取下列方式：
+ 針對公有子網路中的任務，您必須在啟動任務時，將 **Auto-assign public IP** (自動指派公有 IP) 指定為 **ENABLED** (啟用)。如需詳細資訊，請參閱[將應用程式作為 Amazon ECS 任務執行](standalone-task-create.md)。
+ 針對在私有子網路中的任務，則必須在啟動任務時，將 **Auto-assign public IP** (自動指派公有 IP) 指定為 **DISABLED** (停用)，並設定 VPC 中的 NAT 閘道，以便將請求路由至網際網路。如需詳細資訊，請參閱 *Amazon VPC 使用者指南*中的 [NAT 閘道](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html)。

## API 錯誤
<a name="pull-request-api-error"></a>

此錯誤表示 Amazon ECR 端點存在連線問題。

如需如何解決此問題的資訊，請參閱 支援 網站上的[如何解決 Amazon ECS 中的 Amazon ECR 錯誤「CannotPullContainerError： API 錯誤」](https://aws.amazon.com/premiumsupport/knowledge-center/ecs-pull-container-api-error-ecr/)。

## write /var/lib/docker/tmp/*GetImageBlob111111111*: no space left on device
<a name="pull-request-write-error"></a>

此錯誤表示磁碟空間不足。

若要解決這個問題，請釋放磁碟空間。

如果使用 Amazon ECS 最佳化 AMI，您可以透過下列命令來擷取檔案系統上最大的前 20 個檔案：

```
du -Sh / | sort -rh | head -20
```

輸出範例：

```
5.7G    /var/lib/docker/containers/50501b5f4cbf90b406e0ca60bf4e6d4ec8f773a6c1d2b451ed8e0195418ad0d2
1.2G    /var/log/ecs
594M    /var/lib/docker/devicemapper/mnt/c8e3010e36ce4c089bf286a623699f5233097ca126ebd5a700af023a5127633d/rootfs/data/logs
...
```

在某些情況下，執行容器可能會填滿根磁碟區。如果容器使用預設的 `json-file` 日誌驅動程式，而不具有 `max-size` 限制，則該日誌檔案可能佔用大部分空間。您可以使用 `docker ps` 命令，透過將目錄名稱從上面的輸出映射至容器 ID，來驗證哪個容器正在使用該空間。例如：

```
CONTAINER ID   IMAGE                            COMMAND             CREATED             STATUS              PORTS                            NAMES
50501b5f4cbf   amazon/amazon-ecs-agent:latest   "/agent"            4 days ago          Up 4 days                                            ecs-agent
```

在預設情況下，當使用 `json-file` 日誌驅動程式時，Docker 會擷取所有容器的標準輸出 (和標準錯誤)，並使用 JSON 格式將其寫入檔案中。您可以將 `max-size` 設定為日誌驅動程式選項，以防止日誌檔案佔用過多空間。如需詳細資訊，請參閱 Docker 文件中的 [JSON File logging driver](https://docs.docker.com/engine/logging/drivers/json-file/)。

下列是一個容器定義片段，顯示如何使用此選項：

```
{
    "log-driver": "json-file",
    "log-opts": {
        "max-size": "256m"
    }
}
```

如果容器日誌佔用太多磁碟空間，則可使用 `awslogs` 日誌驅動程式。`awslogs` 日誌驅動程式會將日誌傳送至 CloudWatch，以釋放原本要給容器執行個體上的容器日誌使用的磁碟空間。如需詳細資訊，請參閱[將 Amazon ECS 日誌傳送至 CloudWatch](using_awslogs.md)。

您可能需要更新 Docker 可存取的磁碟大小。

如需詳細資訊，請參閱 [CannotPullContainerError: no space left on device](https://repost.aws/questions/QUx6Ix1R1SSNisYSs1Sw8EBA/cannotpullcontainererror-no-space-left-on-device)。

## ERROR: toomanyrequests: Too Many Requests or You have reached your pull rate limit.
<a name="container-pull-too-many-requests"></a>

此錯誤表示存在 Docker Hub 速率限制。

如果收到下列其中一項錯誤訊息，您很可能會達到 Docker Hub 速率限制：

如需 Docker Hub 速率限制的詳細資訊，請參閱[了解 Docker Hub 速率限制](https://www.docker.com/increase-rate-limits)。

如果您已提升 Docker Hub 速率限制，並且需要身分驗證容器執行個體的 Docker 提取，請參閱[容器執行個體的私有登錄檔身分驗證](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/private-auth-container-instances.html)。

## Error response from daemon: Get *url*: net/http: request canceled while waiting for connection
<a name="container-pull-request-canceled-connection"></a>

此錯誤表示連線已逾時，原因是不存在通往網際網路的路由。

要解決此問題，則可以採取下列方式：
+ 針對公有子網路中的任務，您必須在啟動任務時，將 **Auto-assign public IP** (自動指派公有 IP) 指定為 **ENABLED** (啟用)。如需詳細資訊，請參閱[將應用程式作為 Amazon ECS 任務執行](standalone-task-create.md)。
+ 針對在私有子網路中的任務，則必須在啟動任務時，將 **Auto-assign public IP** (自動指派公有 IP) 指定為 **DISABLED** (停用)，並設定 VPC 中的 NAT 閘道，以便將請求路由至網際網路。如需詳細資訊，請參閱 *Amazon VPC 使用者指南*中的 [NAT 閘道](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html)。

## ref pull has been retried 1 time(s): failed to copy: httpReaderSeeker: failed open: unexpected status code
<a name="container-pull-failed-open"></a>

此錯誤表示複製映像時失敗。

若要解決此問題，請檢閱下列文章：
+ 如需 Fargate 任務，請參閱[如何解決 Fargate 上 Amazon ECS 任務的 "cannotpullcontainererror" 錯誤](https://aws.amazon.com/premiumsupport/knowledge-center/ecs-fargate-pull-container-error/)。
+ 如需其他任務，請參閱[如何解決 Fargate 上 Amazon ECS 任務的 "cannotpullcontainererror" 錯誤](https://aws.amazon.com/premiumsupport/knowledge-center/ecs-pull-container-error/)。

## pull access denied
<a name="container-pull-access-denied.title"></a>

此錯誤表示無法存取映像。

若要解決此問題，您可能需要使用 Amazon ECR 驗證 Docker 用戶端。如需詳細資訊，請參閱 *Amazon ECR User Guide* 中的 [Private registry authentication](https://docs.aws.amazon.com/AmazonECR/latest/userguide/registry_auth.html)。

## pull command failed: panic: runtime error: invalid memory address or nil pointer dereference
<a name="container-pull-runtime-error.title"></a>

此錯誤表示由於記憶體位址無效或空指標解除參照，無法存取映像。

若要解決此問題：
+ 檢查您是否擁有可連接 Amazon S3 的安全群組規則。
+ 使用閘道端點時，必須在路由表中新增路由，才能存取端點。

## error pulling image conf/error pulling image configuration
<a name="container-pull-pulling-image.title"></a>

此錯誤表示已達到速率限制或發生網路錯誤：

若要解決此問題，請參閱[我的 Amazon ECS EC2 啟動類型任務中的如何解決「CannotPullContainerError」錯誤](https://repost.aws/knowledge-center/ecs-pull-container-error)。

## 內容已取消
<a name="container-pull-context-canceled"></a>

此錯誤表示內容已取消。

此錯誤的原因通常是因為您的任務所使用的 VPC 沒有路由，而無法從 Amazon ECR 提取容器映像。