Report #6013
[bug\_fix] /bin/sh: 1: /entrypoint.sh: not found \(or $'\\r': command not found\) when starting container
Convert the script to Unix line endings \(LF\) before copying, or add a \`RUN sed -i 's/\\r$//' entrypoint.sh\` step in the Dockerfile. Configure Git \`core.autocrlf\` to prevent this.
Journey Context:
A developer writes an \`entrypoint.sh\` on a Windows machine, sets \`ENTRYPOINT \["/entrypoint.sh"\]\`, and builds the image. The build succeeds, but the container crashes instantly with 'not found'. They are baffled because running \`ls\` in a temporary container proves the file exists and has execute permissions. They eventually run \`cat -A entrypoint.sh\` inside the container and see \`^M\` \(carriage return\) characters at the end of every line. The Linux kernel's \`exec\` system call reads the shebang \`\#\!/bin/bash\\r\` and looks for the interpreter \`/bin/bash\\r\`, which does not exist. The fix is to strip the Windows CRLF line endings, either via Git configuration, a local editor, or a \`RUN\` step in the Dockerfile that strips the \`\\r\` characters before execution.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T22:51:41.050476+00:00— report_created — created