{
  "id": "docker/compose-version-attribute-obsolete",
  "signature": "WARNING: The 'version' attribute in docker-compose.yml is obsolete. Use 'services' directly without 'version'.",
  "signature_zh": "警告：docker-compose.yml 中的 'version' 属性已过时。请直接使用 'services' 而不使用 'version'。",
  "regex": "WARNING: The 'version' attribute in docker-compose\\.yml is obsolete",
  "domain": "docker",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "Docker Compose v2.20+ no longer supports the 'version' top-level key; it was used in legacy Compose v1 files and is now ignored or causes a warning.",
  "root_cause_type": "generic",
  "root_cause_zh": "Docker Compose v2.20+ 不再支持顶级 'version' 键；该键用于旧版 Compose v1 文件，现在被忽略或导致警告。",
  "versions": [
    {
      "version": "Docker Compose v2.20.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Docker Compose v2.21.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Docker Compose v2.22.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Docker Desktop 4.24.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Updating the 'version' value to '3.9' or '3.8' thinking it is a version mismatch",
      "why_fails": "The warning is not about the version number being wrong; the entire attribute is deprecated. Changing the value does not remove the warning.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "Ignoring the warning because 'docker compose up' still works",
      "why_fails": "While the warning does not prevent execution, future versions of Docker Compose may treat the presence of 'version' as a fatal error, breaking the setup.",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    },
    {
      "action": "Downgrading Docker Compose to v1 to keep using the 'version' attribute",
      "why_fails": "Docker Compose v1 is deprecated and no longer receives security updates; downgrading introduces risks and is not a sustainable solution.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Remove the 'version' line from docker-compose.yml entirely. The file should start with 'services:' directly. Example: replace 'version: \"3.8\"\\nservices:' with 'services:'.",
      "success_rate": 0.95,
      "how": "Remove the 'version' line from docker-compose.yml entirely. The file should start with 'services:' directly. Example: replace 'version: \"3.8\"\\nservices:' with 'services:'.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If you need to support both Compose v1 and v2, use a conditional check in your CI/CD: 'if docker compose version | grep -q v2; then sed -i '/^version:/d' docker-compose.yml; fi'.",
      "success_rate": 0.85,
      "how": "If you need to support both Compose v1 and v2, use a conditional check in your CI/CD: 'if docker compose version | grep -q v2; then sed -i '/^version:/d' docker-compose.yml; fi'.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use 'docker compose config' to validate and migrate your file: it will output the normalized config without the 'version' attribute, which you can redirect to a new file.",
      "success_rate": 0.9,
      "how": "Use 'docker compose config' to validate and migrate your file: it will output the normalized config without the 'version' attribute, which you can redirect to a new file.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "完全从 docker-compose.yml 中删除 'version' 行。文件应直接以 'services:' 开头。例如：将 'version: \"3.8\"\\nservices:' 替换为 'services:'。",
    "如果需要同时支持 Compose v1 和 v2，在 CI/CD 中使用条件检查：'if docker compose version | grep -q v2; then sed -i '/^version:/d' docker-compose.yml; fi'。",
    "使用 'docker compose config' 验证并迁移文件：它会输出没有 'version' 属性的标准化配置，你可以将其重定向到新文件。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.docker.com/compose/compose-file/04-version-and-name/",
  "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": []
}