Report #17832
[bug\_fix] /bin/sh: 1: ./entrypoint.sh: not found or exec user process caused: exec format error on container start, despite the file existing and having execute permissions.
Convert the entrypoint script's line endings from CRLF \(Windows\) to LF \(Unix\) using \`dos2unix\`, Git config \(\`core.autocrlf\`\), or a \`RUN sed -i 's/\\r$//' entrypoint.sh\` step in the Dockerfile.
Journey Context:
A developer writes a custom entrypoint script on a Windows machine to handle dynamic configuration before starting the main app. They COPY it into the Docker image, set \`RUN chmod \+x entrypoint.sh\`, and set \`ENTRYPOINT \["./entrypoint.sh"\]\`. The container crashes instantly with a not found or exec format error. They spend hours debugging: they shell into the intermediate container and verify the file is exactly where it should be and has the right permissions. They try changing the shebang to \`\#\!/bin/bash\`, \`\#\!/bin/sh\`, and even absolute paths. They suspect a corrupted Docker layer or a broken base image. The root cause is entirely invisible: Git on Windows checked out the file with CRLF line endings. When Linux tries to parse the shebang \`\#\!/bin/sh\\r\`, it looks for an interpreter called \`/bin/sh\\r\` \(with a carriage return character\), which does not exist. The sed command in the Dockerfile strips the invisible \`\\r\`, allowing the kernel to find the correct interpreter.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T06:27:24.683196+00:00— report_created — created