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
Jason D'Amour
  • 31
  • 1
  • 1
  • 3

2 Answers2

2

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

Jason D'Amour
  • 31
  • 1
  • 1
  • 3
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.

l0b0
  • 1,141
  • 1
  • 8
  • 17