Docker "exec /entrypoint.sh: no such file or directory" (CRLF) in CI
The container fails to start with "no such file or directory" even though the entrypoint exists. The real culprit is the shebang: a trailing carriage return from CRLF line endings makes the kernel look for an interpreter named /bin/sh\r, which does not exist.
What this error means
The image builds, but starting it fails with "exec /entrypoint.sh: no such file or directory" although the file is present and executable. The script was committed with Windows CRLF line endings.
exec /entrypoint.sh: no such file or directoryCommon causes
CRLF line endings in the shebang
The shebang reads #!/bin/sh\r; the kernel includes the trailing \r in the interpreter path, cannot find it, and reports ENOENT as "no such file or directory".
A missing or wrong interpreter
The shebang names an interpreter not installed in the image (for example /bin/bash on Alpine), producing the same not-found error.
How to fix it
Strip carriage returns and enforce LF
Convert the script to LF endings, in the image or via .gitattributes.
RUN sed -i 's/\r$//' /entrypoint.sh
# or commit a .gitattributes rule:
# *.sh text eol=lfEnsure the interpreter exists
- Confirm the shebang names an interpreter present in the image.
- On Alpine, use
/bin/shor installbashbefore using it. - Rebuild and start the container to confirm it runs.
How to prevent it
- Commit shell scripts with LF endings via
.gitattributes. - Point the shebang at an interpreter the image actually has.
- Remember ENOENT here means a missing interpreter, not a missing file.