{
  "id": "docker/compose-service-dependency-cycle",
  "signature": "ERROR: Circular dependency detected: service1 depends on service2 which depends on service1",
  "signature_zh": "错误：检测到循环依赖：service1 依赖于 service2，而 service2 又依赖于 service1",
  "regex": "Circular dependency detected.*depends on.*which depends on",
  "domain": "docker",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "In a docker-compose.yml file, services have a circular dependency chain via the 'depends_on' directive, which Docker Compose cannot resolve.",
  "root_cause_type": "generic",
  "root_cause_zh": "在 docker-compose.yml 文件中，服务通过 'depends_on' 指令形成了循环依赖链，Docker Compose 无法解析。",
  "versions": [
    {
      "version": "Docker Compose v2.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Docker Compose v2.20.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Docker Compose v2.24.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Removing all depends_on directives breaks the intended startup order and may cause runtime failures if services depend on each other for readiness.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Adding a third service that depends on both only masks the cycle temporarily; the underlying dependency graph remains invalid.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Redesign the service architecture to remove the circular dependency. For example, if service A needs service B and vice versa, consider merging them into a single service or using a message queue. Update docker-compose.yml to remove the cycle.",
      "success_rate": 0.95,
      "how": "Redesign the service architecture to remove the circular dependency. For example, if service A needs service B and vice versa, consider merging them into a single service or using a message queue. Update docker-compose.yml to remove the cycle.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use 'depends_on' with 'condition: service_healthy' and implement health checks instead of direct dependencies. This allows services to start in any order but wait for readiness. Example: 'depends_on: { db: { condition: service_healthy } }'.",
      "success_rate": 0.85,
      "how": "Use 'depends_on' with 'condition: service_healthy' and implement health checks instead of direct dependencies. This allows services to start in any order but wait for readiness. Example: 'depends_on: { db: { condition: service_healthy } }'.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Redesign the service architecture to remove the circular dependency. For example, if service A needs service B and vice versa, consider merging them into a single service or using a message queue. Update docker-compose.yml to remove the cycle.",
    "Use 'depends_on' with 'condition: service_healthy' and implement health checks instead of direct dependencies. This allows services to start in any order but wait for readiness. Example: 'depends_on: { db: { condition: service_healthy } }'."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.docker.com/compose/compose-file/05-services/#depends_on",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.95,
  "resolvable": "true",
  "first_seen": "2023-11-01",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}