{
  "id": "docker/entrypoint-script-dos-line-endings",
  "signature": "exec /entrypoint.sh: exec format error: /usr/bin/env: 'bash\\r': No such file or directory",
  "signature_zh": "exec /entrypoint.sh: exec 格式错误：/usr/bin/env: 'bash\\r': 没有那个文件或目录",
  "regex": "exec [\\w/.-]+: exec format error: /usr/bin/env: '[\\w]+\\\\r': No such file or directory",
  "domain": "docker",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The entrypoint script has Windows-style CRLF line endings (\\r\\n) instead of Unix-style LF (\\n), causing the shebang interpreter to fail when it tries to execute 'bash\\r' (with a carriage return character).",
  "root_cause_type": "generic",
  "root_cause_zh": "入口点脚本具有 Windows 风格的 CRLF 换行符（\\r\\n）而不是 Unix 风格的 LF（\\n），导致 shebang 解释器尝试执行 'bash\\r'（包含回车符）时失败。",
  "versions": [
    {
      "version": "Docker 20.10.22",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Docker 24.0.4",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Docker 25.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The issue is not the shell type but the carriage return character in the shebang line; changing the shebang does not remove the \\r character.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The base image does not affect the line endings of the script; the problem is in the script file itself, which is copied from the host.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The container fails to start due to the entrypoint error, so 'docker exec' cannot be used because the container is not running.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Convert the entrypoint script to Unix line endings using 'dos2unix' on the host: 'dos2unix entrypoint.sh' before building the image, or use 'sed -i 's/\\r$//' entrypoint.sh'.",
      "success_rate": 0.95,
      "how": "Convert the entrypoint script to Unix line endings using 'dos2unix' on the host: 'dos2unix entrypoint.sh' before building the image, or use 'sed -i 's/\\r$//' entrypoint.sh'.",
      "condition": "",
      "sources": []
    },
    {
      "action": "In the Dockerfile, add a RUN command to fix line endings after COPY: 'RUN sed -i 's/\\r$//' /entrypoint.sh'.",
      "success_rate": 0.9,
      "how": "In the Dockerfile, add a RUN command to fix line endings after COPY: 'RUN sed -i 's/\\r$//' /entrypoint.sh'.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Configure Git to automatically convert line endings on checkout by setting 'git config core.autocrlf input' on the host, then re-clone or checkout the repository.",
      "success_rate": 0.85,
      "how": "Configure Git to automatically convert line endings on checkout by setting 'git config core.autocrlf input' on the host, then re-clone or checkout the repository.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "在主机上使用 'dos2unix' 将入口点脚本转换为 Unix 换行符：'dos2unix entrypoint.sh'，或在构建镜像前使用 'sed -i 's/\\r$//' entrypoint.sh'。",
    "在 Dockerfile 中，在 COPY 之后添加 RUN 命令修复换行符：'RUN sed -i 's/\\r$//' /entrypoint.sh'。",
    "配置 Git 在检出时自动转换换行符：在主机上设置 'git config core.autocrlf input'，然后重新克隆或检出仓库。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.docker.com/engine/reference/builder/#entrypoint",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.95,
  "resolvable": "true",
  "first_seen": "2023-08-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}