0

I am trying to write a simple dockerfile that wraps around a bash script. The docker file looks like this:

FROM openjdk:8-jre-alpine COPY . /build/demo WORKDIR /build/demo/ RUN pwd; ls RUN chmod +x run-demo.sh RUN run-demo.sh 1 zk 

and the context file directory (slimmed down) looks like:

  • Dockerfile
  • build
    • demo
      • run-demo.sh

I have a step RUN pwd; ls which outputs

RUN pwd; ls ---> Running in f22ce9175cee /build/demo run-demo.sh 

and yet once the docker build . reaches the last command, it says /bin/sh: run-demo.sh: not found. How is that possible? Thank you

edit: and the script begins with !#/bin/bash if thats relevant edit2:

RUN pwd; ls -l ---> Running in 16fbda2c19e1 /build/demo -rwxr-xr-x 1 root root 775 Jun 12 21:14 run-demo.sh Removing intermediate container 16fbda2c19e1 ---> bf8ada47953a Step 7/7 : RUN ./run-demo.sh 1 zk ---> Running in daccefe3c895 /bin/sh: ./run-demo.sh: not found 

2 Answers 2

2

I have solved it. openjdk:8-jre-alpine, my base image, does not pack bash

0

To run a program directly, as you are trying, it must be in one of the directories listed in the PATH variable. To run a file elsewhere you need to explicitly provide the path to it, as in either ./run-demo.sh or /build/demo/run-demo.sh.

2
  • This was how I first wrote my docker file, it has no effect on the error Commented Jun 13, 2018 at 15:54
  • I added an edit to the question Commented Jun 13, 2018 at 16:12

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.