# 错误：服务 'docker' 不可用。请检查服务是否正在运行且可访问。

- **ID:** `cicd/bitbucket-pipeline-service-unavailable`
- **领域:** cicd
- **类别:** system_error
- **错误码:** `SERVICE_UNAVAILABLE`
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

Bitbucket Pipelines无法启动Docker服务，因为管道的构建容器没有Docker守护进程访问权限，或者bitbucket-pipelines.yml中的服务定义配置错误。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Bitbucket Pipelines 2024 | active | — | — |
| Docker 24.0 | active | — | — |
| Ubuntu 22.04 | active | — | — |

## 解决方案

1. ```
   Add the Docker service to bitbucket-pipelines.yml:
definitions:
  services:
    docker:
      image: docker:24.0
pipelines:
  default:
    - step:
        services:
          - docker
        script:
          - docker info
   ```
2. ```
   Use a Bitbucket pipeline image that includes Docker pre-installed, such as atlassian/default-image:4
   ```

## 无效尝试

- **Add 'docker: true' to the step definition without defining services** — Docker service must be explicitly listed under 'services:' in the pipeline YAML (90% 失败率)
- **Use a custom Docker image without checking if it has Docker installed** — The service requires Docker daemon, which may not be present in custom images (70% 失败率)
- **Set DOCKER_HOST environment variable to a remote daemon** — Bitbucket Pipelines blocks external network connections from services for security (85% 失败率)
