The script has Windows line endings
CommonThe entrypoint was edited or checked out on Windows (or with core.autocrlf), so its first line is #!/bin/sh followed by a carriage return. The kernel looks for an interpreter literally named /bin/sh\r, which does not exist.
Confirm
file entrypoint.sh head -1 entrypoint.sh | od -c | head -2
with CRLF line terminators, and \r before \n on the first line
Fix
- Convert the file to LF: sed -i 's/\r$//' entrypoint.sh (GNU sed; on macOS sed -i '' 's/\r$//' entrypoint.sh), or dos2unix entrypoint.sh, and commit it.
- Stop it coming back: add a .gitattributes line such as *.sh text eol=lf, so Git checks scripts out with LF on every machine.
- Or normalise during the build: RUN sed -i 's/\r$//' /usr/local/bin/entrypoint.sh in the Dockerfile.
printf '*.sh text eol=lf\n' >> .gitattributes && git add --renormalize . && git commit -m 'Scripts use LF'
Then rebuild the image. --renormalize rewrites files already committed to match the new rule; checked on Git 2.50.1 with a CRLF script.