Skip to content
Latchkey

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.

docker
exec /entrypoint.sh: no such file or directory

Common 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.

Dockerfile
RUN sed -i 's/\r$//' /entrypoint.sh
# or commit a .gitattributes rule:
# *.sh text eol=lf

Ensure the interpreter exists

  1. Confirm the shebang names an interpreter present in the image.
  2. On Alpine, use /bin/sh or install bash before using it.
  3. 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.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →