I received this error message which means something is erroring inside a bash script executed by the Dockerfile.
As an example, if something inside test.sh errors:
RUN test.sh # 16 ERROR: executor failed running [/bin/sh -c test.sh]: exit code: 127 Question
What is the recommended way to gain visibility over the exact error message (i.e. to find out what's gone wrong) and to diagnose which line(s) of a bash script executed from a Dockerfile are problematic? Can docker be made to provide the output of the bash script so the exact error message is provided? Rather than just the somewhat cryptic:
executor failed running exit code: 127 as seen here.
What I know so far
One way to diagnose which line(s) is playing up is to survey the script, assess which line(s) might be causing problems, and comment out the suspect line and everything after it. If the error goes away, you've found the (first) line that is a problem, and it can be addressed. Rinse and repeat until the script is error-free. But this seems more manual than one would hope.
-xoption could potentially help here – addset -xinside your script, or explicitly run it withRUN sh -x your_script.sh– but "exit code: 127" sort of sounds like it's maybe a wrong-architecture image, or the script names an interpreter that's not present in your image (not all Docker images contain bash for example). Just as you've shown it it's also possible thattest.shisn't in$PATHanywhere and you need toRUN ./test.sh.RUN sh -x your_script.sh, thank you. You can make it an answer is you think it may help others.