I am trying to copy the outputs to distroless image
The scripts folder contain a python file named start
FROM <some image> as custom-image
RUN mkdir scripts
COPY scripts/start scripts/start
FROM gcr.io/distroless/python3
COPY --from=custom-image /scripts /scripts
when I run the container and go into the terminal:
# cd scripts
# ./start
/bin/sh: 3: ./start: Permission denied
#
Now when I add the chmod line:
RUN chmod +x scripts/start
FROM gcr.io/distroless/python3
COPY --from=custom-image /scripts /scripts
and I attempt to run the start script in terminal again:
/bin/sh: 3: ./start: not found
How are you trying to run this script "in terminal"?
Your final image already has an ENTRYPOINT (
[/usr/bin/python3.9]):So your final stage could look something like this:
I also added and commnented out the
chmodhere to point out that it is not needed. Since the entrypoint for the distroless image is/usr/bin/python3.9, what will actually the run in the end is/usr/bin/python3.9 scripts/start, which means the script doesn't need to be executable.If you don't want the
CMDthen you can just add/scripts/startat yourdocker run <final_image>script.