# 已停止（CannotStartContainerError：API 错误 (500)：devmapper：精简池有 X 个空闲数据块，少于所需的最小 X 个总数据块）

- **ID:** `aws/ecs-task-stopped-cannotstartcontainererror`
- **领域:** aws
- **类别:** resource_error
- **错误码:** `CannotStartContainerError`
- **验证级别:** ai_generated
- **修复率:** 75%

## 根因

ECS 任务失败，因为容器实例上的 Docker 存储驱动程序（devicemapper）的精简池中的空闲数据块不足，通常是由于磁盘空间耗尽或 Docker 存储配置错误。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| ECS 1.62.0 | active | — | — |
| Docker 20.10.17 | active | — | — |
| Amazon Linux 2 | active | — | — |

## 解决方案

1. ```
   Run `docker system prune -a --volumes` on the container instance to remove unused Docker objects and free thin pool space. Then restart the ECS task.
   ```
2. ```
   Increase the Docker base device size by editing `/etc/docker/daemon.json` to set `{"storage-opts": ["dm.basesize=50G"]}` and restarting Docker service.
   ```

## 无效尝试

- **Manually restarting the ECS agent or the container instance without cleaning up unused images/containers.** — The underlying thin pool is still full; restarting does not free data blocks. (90% 失败率)
- **Increasing the ECS task memory limit without addressing Docker storage.** — The error is about disk storage blocks, not memory allocation. (95% 失败率)
