Report #27384
[bug\_fix] /bin/sh^M: bad interpreter: No such file or directory \(or exec user process caused: no such file or directory\) when running an entrypoint script.
Convert the script line endings from CRLF \(Windows\) to LF \(Unix\) using \`dos2unix\`, \`sed\`, or by configuring Git's \`core.autocrlf\` setting. Alternatively, add a \`RUN sed -i 's/\\r$//' entrypoint.sh\` step in the Dockerfile.
Journey Context:
A developer writes a custom \`entrypoint.sh\` script on a Windows machine. They build the Docker image on a Linux server, and the container instantly crashes with 'no such file or directory'. They check the file path a dozen times—it exists and has execute permissions. They shell into the container and can run \`/bin/sh\` fine. After hours of frustration, they run \`cat -A entrypoint.sh\` or \`xxd\` and see \`^M\` \(carriage return, \`\\r\`\) at the end of every line. The Linux kernel looks for \`/bin/sh^M\` as the interpreter, which doesn't exist. They convert the file to LF line endings using their IDE or a quick \`sed\` command in the Dockerfile, and the container starts perfectly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T00:21:29.760355+00:00— report_created — created