4

I am trying to add bash to a "FROM Scratch" docker image.

I've copied a bash binary from the official bash docker image from docker hub (https://hub.docker.com/_/bash)

docker run -d bash:latest sleep 100
docker cp "$bash_container_id":/usr/local/bin/bash .

My Dockerfile is as follows

FROM jaegertracing/all-in-one:latest
COPY bin/bash /bin
ENV PATH "$PATH:bin/bash"
RUN ["bash"]

Which, when building, results in

Sending build context to Docker daemon  5.213MB
Step 1/4 : FROM jaegertracing/all-in-one:latest
latest: Pulling from jaegertracing/all-in-one
023a144cdcf7: Already exists 
d247ed88ca7d: Already exists 
dc4682d67823: Already exists 
Status: Downloaded newer image for jaegertracing/all-in-one:latest
 ---> b64ba73d1fa4
Step 2/4 : COPY bin/bash /bin
 ---> b6e8ae824d24
Step 3/4 : ENV PATH "$PATH:bin/bash"
 ---> Running in eda2042dff57
Removing intermediate container eda2042dff57
 ---> f1288ded6fcf
Step 4/4 : RUN ["bash"]
 ---> Running in 616c80b0cb8c
OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"bash\": executable file not found in $PATH": unknown

the jaegertracing/all-in-one image is using a "Scratch" base image that contains nothing (no sh, no bash, etc) I am trying to add bash to it for debugging reasons.

Any suggestions? Thanks in advance

PPetkov
  • 240
  • 3
  • 13

1 Answers1

1

You did not configure your $PATH correctly. The path is a series of directories to look for an executable in, not the path of the executables themselves. Also, since you are moving bin/bash to /bin/bash, you should not be worrying about adding bin/bash to the path. But either way, what you want is either

  1. ENV PATH "$PATH:bin"
  2. ENV PATH "$PATH:/bin"

I believe what you want is option #2, as it is where you have copied bash to.

Edward Minnix
  • 2,889
  • 1
  • 13
  • 26
  • 1
    Thanks for getting involved. I tried both `Step 3/4 : ENV PATH "$PATH:bin"` and `Step 3/4 : ENV PATH "$PATH:/bin"` but the result is till the same `OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"bash\": executable file not found in $PATH": unknown` – PPetkov Aug 13 '19 at 14:16