Google Distroless image chmod not found?

981 Views Asked by At

I am using this:

FROM gcr.io/distroless/python3-debian11

When I build my docker file,

 > [stage-1 6/6] RUN /chmod +x /scripts/main:
#17 0.204 /bin/sh: 1: /chmod: not found

Why is chmod and ls not found?

When I try to ls inside the container:

# /bin/sh ls
/bin/sh: 0: cannot open ls: No such file
1

There are 1 best solutions below

4
The Fool On

That is intentional. Conceptionally, there is nothing inside the image. It's not as bare-bones as scratch but close.

If you need to perform some work, do it up front in another stage.

FROM python 
RUN chmod +x /tmp/foo

FROM gcr.io/distroless/python3-debian11
COPY --from=0 /tmp/foo /opt/app 

That said, in your case you may be able to get away with

FROM gcr.io/distroless/python3-debian11
COPY --chmod=755 /my/local/script.py /opt/app.py