I’m a beginner with Docker and I have a really basic Dockerfile for practicing purposes.
FROM debian:latest
WORKDIR /init
COPY hello_world.sh .
RUN hello_world.sh
CMD [ "/bin/bash" ]
After I try to build the image, I get this:
Sending build context to Docker daemon 3.072kB
Step 1/5 : FROM debian:latest
---> ee11c54e6bb7
Step 2/5 : WORKDIR /init
---> Using cache
---> 605ee1ff67e9
Step 3/5 : COPY hello_world.sh .
---> Using cache
---> f544ee4e93b8
Step 4/5 : RUN hello_world.sh
---> Running in c4cbd6389bc2
/bin/sh: 1: hello_world.sh: not found
The command '/bin/sh -c hello_world.sh' returned a non-zero code: 127
If I modify the RUN directive and set an absolute path /init/hello_world.sh, it works well. Based on the description, the above Dockerfile should work.
From the Dockerfile reference:
The WORKDIR instruction sets the working directory for any RUN, CMD, ENTRYPOINT, COPY and ADD instructions that follow it in the Dockerfile.
What did I misunderstand?