SH script in $PATH is not found on Linux Alpine 3.11

Your interactive shell is dash (masquerading as sh). The dash shell says

sh: /usr/local/bin/wait-for: not found

when it tries to execute a script that has a faulty #!-line pointing to an interpreter that can't be found. It happens to be exactly the same error that you would get when the command that you type can't be found, so it's easy to think it's a $PATH issue (it's not in this case). Oher shells have more informative error messages (bash and zsh says "bad interpreter: No such file or directory" and also tells you what interpreter it tried to execute).

Since the file is a DOS text file, the #!-line instructs the shell to run the script with /bin/sh\r, where \r is a common representation of a carriage return character, which is part of the line termination in DOS text files. On a Unix system, a carriage return is an "ordinary character" and not at all part of the line termination, which mean that it tries to start /bin/sh\r to run your script, and then fails as that file does not exist. It is therefore the interpreter that is "not found", not the script itself.

Running the script with an explicit interpreter bypasses the #!-line, always, which is why you don't get the error when you do that. However, each line in the script would still have the carriage returns at the end of them, which may cause the script to malfunction under some conditions.

Simply re-saving the file as a Unix text file, or converting it with dos2unix, would resolve your issue.