Saskia
Saskia

Reputation: 1056

How to run a simple #!/bin/sh script in alpine on Docker for Windows

I'm trying to add a script to an alpine linux docker file, but am unable to run the script. It always results in

/bin/sh: /tmp/test.sh: not found 
The command '/bin/sh -c /tmp/test.sh' returned a non-zero code: 127 

The file has the executable flag set.

Dockerfile:

FROM alpine

ADD test.sh /tmp/test.sh
RUN /tmp/test.sh

test.sh

#!/bin/sh

echo "Hello World"

output

docker build --no-cache . 
Sending build context to Docker daemon  3.072kB 
Step 1/3 : FROM alpine 
 ---> cdf98d1859c1
Step 2/3 : ADD test.sh /tmp/test.sh
 ---> c81abfa30514 
Step 3/3 : RUN /tmp/test.sh
 ---> Running in 73b702648827 
/bin/sh: /tmp/test.sh: not found 
The command '/bin/sh -c /tmp/test.sh' returned a non-zero code: 127 

Upvotes: 2

Views: 1832

Answers (1)

Mihai
Mihai

Reputation: 10717

Make sure that your file (test.sh) is saved in unix format if you are working on Windows.

Upvotes: 1

Related Questions