This obscure error plagued me a long time. This occurred in the context when trying to build a linux docker on a Windows host while trying to ask the Dockerfile to copy over a XXXX.sh file (name doesn’t matter) when it was originally created on windows and trying to execute it as RUN/CMD/ENTRY in the linux docker.
The problem is because of damn CRLF issue. Convert the XXXX.sh file into LF format and that will solve the problem.
See the source of the solution at https://github.com/postlight/headless-wp-starter/issues/171