Docker "standard_init_linux.go: ... no such file or directory" (Entrypoint) in CI
The runtime tried to exec the entrypoint and the kernel reported no such file or directory - even though the script exists. The usual cause is a CRLF (Windows) line ending in the shebang, or a shebang pointing at an interpreter that is not in the image.
What this error means
A container exits at start with standard_init_linux.go:<n>: exec user process caused: "no such file or directory". The entrypoint file is present, but its interpreter cannot be found.
standard_init_linux.go:228: exec user process caused: no such file or directory
# entrypoint.sh has CRLF line endings, so the shebang "#!/bin/sh\r" is invalidCommon causes
CRLF line endings in the entrypoint script
A #!/bin/sh\r shebang (Windows CRLF) makes the kernel look for an interpreter named /bin/sh\r, which does not exist - reported as no such file or directory.
A shebang interpreter missing from the image
A script with #!/bin/bash on a base image that only has sh (no bash) fails because the interpreter is absent.
A statically-wrong interpreter path
A shebang pointing at a path the image does not provide produces the same kernel error at exec time.
How to fix it
Normalize line endings and the shebang
Convert CRLF to LF and use an interpreter the image has.
# build-time: strip CR and ensure executable
COPY entrypoint.sh /entrypoint.sh
RUN sed -i 's/\r$//' /entrypoint.sh && chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]Enforce LF in the repo
Add a .gitattributes rule so shell scripts stay LF.
# .gitattributes
*.sh text eol=lfHow to prevent it
- Force LF line endings for shell scripts via
.gitattributes. - Use a shebang interpreter the base image actually provides.
- chmod +x entrypoint scripts during the build.