docker alpine /bin/sh script.sh not found

Viewed 37501

I'm trying to build a docker image that has the openjdk:8-alpine as base.
The problem is when I try to execute a script.sh, returning me the following message:

/bin/sh: bin/script.sh: not found

The script.sh is in the bin/ folder correctly, that's why I don't know what's the problem.

Anyone have any idea?

Thank you.

4 Answers

Make sure the shebang on the script points to an interpreter that actually exists. Thus, if the script being invoked uses:

#!/bin/bash

...then /bin/bash needs to actually be installed. (Alternately, you might consider trying to port the script to work with POSIX sh, and modifying its shebang to /bin/sh).

I was getting the same error message, but my problem was line-endings: my shell-script used MS-DOS line-endings which ash did not like. Once I converted the script file to Unix line-endings, everything worked.

Also ran into this problem. Make sure the .sh file is saved in UNIX encoding.

For me it was UTF-8 (worked) vs UTF-8 with BOM (did not work).

Related