Report #46461
[bug\_fix] /bin/sh: ^M: bad interpreter or exec user process caused: exec format error when starting container
Convert the line endings of the entrypoint script from CRLF \(Windows\) to LF \(Unix\) using tools like dos2unix, or configure Git to not convert LF to CRLF on checkout via .gitattributes.
Journey Context:
A developer builds a Docker image successfully on their Windows machine, but when running it in a Linux-based CI pipeline or cloud environment, the container immediately crashes with a cryptic 'exec format error' or '/bin/sh: ^M' error. They spend hours debugging the base image, shell availability, and file permissions. They eventually inspect the entrypoint script in the container using hexdump or cat -A and spot Windows-style carriage returns \(^M / \\r\). The Linux kernel attempts to execute '/bin/sh\\r' instead of '/bin/sh', which does not exist. The fix works because stripping the \\r characters allows the shebang to resolve to a valid Unix interpreter path.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T08:27:32.038324+00:00— report_created — created