Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`chmod` not working on Dockerfile (macbook)

I'm currently working on a Dockerfile that requires me to have permissions to read, write and execute on two specific folders. When it comes time to run the the chmod commands, it just fail. I can manually change the permissions once inside the docker container but it doesn't seem to pick it up from the command. This is what it looks like currently:

FROM <image-source>
SHELL ["/bin/bash", "-c"]
USER root
WORKDIR /bla/bla
COPY . .
CMD chmod 777 -R /src/main/*
CMD chmod 777 -R /app/main/*
like image 292
Caliman Avatar asked Dec 03 '25 15:12

Caliman


1 Answers

A Dockerfile can only have one CMD instruction, which define the command occuring when the container is launched.

Try to replace these lines:

CMD chmod 777 -R /src/main/*
CMD chmod 777 -R /app/main/*

by:

RUN chmod 777 -R /src/main/*
RUN chmod 777 -R /app/main/*

In this case, chmod commands will occurs when building the image.

like image 131
veben Avatar answered Dec 05 '25 13:12

veben



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!