Sou iniciante no Docker e tenho um Dockerfile realmente básico para fins práticos.
FROM debian:latest
WORKDIR /init
COPY hello_world.sh .
RUN hello_world.sh
CMD [ "/bin/bash" ]
Depois de tentar construir a imagem, recebo o seguinte:
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
Se eu modificar a diretiva RUN e definir um caminho absoluto/init/hello_world.sh, isso funciona bem. Com base na descrição, o Dockerfile acima deve funcionar.
Na referência do Dockerfile:
The WORKDIR instruction sets the working directory for any RUN, CMD, ENTRYPOINT, COPY and ADD instructions that follow it in the Dockerfile.
O que eu entendi mal?
Responder1
Tentar RUN ./hello_world.sh
. O fato de queDIR_TRABALHOusado pelo detetive RUN, não significa que seja automaticamente no PATH. Este ainda é apenas odiretório de trabalhoonde um processo é executado.