Report #93140
[bug\_fix] exec: "/bin/sh": stat /bin/sh: no such file or directory or dockerfile parse error line 1: unknown instruction: %\!s\(MISSING\) when building a Dockerfile created on Windows.
Convert the Dockerfile to LF \(Unix\) line endings using \`dos2unix\` or configure Git to preserve LF endings \(\`git config --global core.autocrlf false\`\).
Journey Context:
A developer working on Windows creates a Dockerfile. It builds fine on their local machine, but when pushed to a Linux CI/CD runner, the build fails with a bizarre parse error or a 'no such file or directory' on \`/bin/sh\`. The error message points to line 1, which is just \`FROM ubuntu\`. The developer wastes hours checking Docker versions, base image names, and BuildKit compatibility. They try rewriting the file from scratch, but the error persists. The root cause is that Windows uses CRLF \(\`\\r\\n\`\) line endings, and Git auto-converted the file. The Linux Docker builder parses the invisible \`\\r\` carriage return as part of the instruction or executable path \(e.g., trying to run \`/bin/sh\\r\` which does not exist in the Linux filesystem\). The fix is to ensure the Dockerfile is saved with LF line endings and to configure Git to not convert them by setting \`core.autocrlf\` to false or adding a \`.gitattributes\` file with \`\*.dockerfile text eol=lf\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T14:55:24.455406+00:00— report_created — created