I have checked line endings and they are all LF but I spotted that the working docker file was as ASCII text and the non working ones were in Unicode UTF-8 when I changed them to ASCII encoding it started to work OK.
ASCII
Unicode UTF-8