Issue
hi i need to chmod this file /root/Desktop/folderdocker/index.php using chmod 774 command
here my dockerfile:
FROM php:7.4-cli
copy . index.php
RUN chmod -R 774 /Dekstop/folderdocker/index.php
RUN chown -R root /var/www
output:
Sending build context to Docker daemon 342.9MB
Step 1/4 : FROM php:7.4-cli
---> f4f453029716
Step 2/4 : copy . index.php
---> Using cache
---> bc9a68fff22f
Step 3/4 : RUN chmod -R 774 /Dekstop/folderdocker/index.php
---> Running in 4ddc85713576
chmod: cannot access '/Dekstop/folderdocker/index.php': No such file or directory```
Solution
You are copying the directory of the Dockerfile into a dir called index.php in the root of your image. Then you are referencing a file in a path that does not exist.
Make sure index.php is next to your Dockerfile, for the next command to work, or you would need to modify the source path.
You should COPY index.php /some/path/or/just/root/index.php
make sure you RUN mkdir if the path does not exist. And then you can chown the file.
In order to be able to see the image you are inheriting from you can run:
docker run -it php:7.4-cli sh
to get a shell in it and see the available dirs.
Answered By - Kroustou Answer Checked By - David Goodson (WPSolving Volunteer)