You copy entrypoint.sh into the image, set it as the ENTRYPOINT , build, run, and get:
$ docker run --rm crlf-demo exec /entrypoint.sh: no such file or directory
Enter fullscreen mode
Exit fullscreen mode
You open a shell in the image and the file is exactly where it should be. The error message is technically true, but it's talking about a different file. Here are three errors from the same family, each reproduced on Docker Engine 29.9, with what they actually mean.
1. no such file or directory : the script has Windows line endings
This one hits almost everyone who builds images on Windows. Look at the bytes of the script:
$ od -c entrypoint.sh | head -n 2 0000000 # ! / b i n / s h \r \n e c h o 0000020 " h e l l o f r o m e n t r
Enter fullscreen mode
Exit fullscreen mode
The first line ends with \r \n (CRLF). When the kernel runs the script, it reads the interpreter from the shebang line up to the \n , so it looks for a program called /bin/sh\r , with an invisible carriage return at the end.…