docker – Dockerfile RUN chmod not taking effect
docker – Dockerfile RUN chmod not taking effect
The directory is defined as a volume upstream: https://github.com/joomla/docker-joomla/blob/d34ff24288dfb5b27a167f870f1fcca56077be78/php7.2/apache/Dockerfile#L64
VOLUME /var/www/html
Volumes cannot be modified with a RUN command. They start in a temporary container that has the volume, and only the changes to the container, not the volume are saved.
You can try asking the upstream repo to change their image to remove the volume definition from the Dockerfile. Or you can pull their repo and build your own version of the base image without the volume. Neither of these will prevent you from running the container later with a volume in that directory.
Otherwise, if you want to extend the image and make changes with RUN commands, youll need to save your files in another directory. You could also have an entrypoint that copies those files to /var/www/html on container start.
You could also consider a multi stage build, fixing the permissions in the first stage, and then copying the files directly into the volume in the release stage. As youve noticed, COPY still works with volumes. It isnt implement with a temporary container and therefore can place files directly in the image filesystem.
You should set the owner directly when you copy the files:
FROM joomla:3.9-php7.2-apache
RUN apt-get update
&& apt-get install -y apt-utils vim curl
COPY --chown=www-data:www-data ./joomla_html /var/www/html
RUN chmod -R 765 /var/www/html/
COPY ./docker/php.ini /usr/local/etc/php/conf.d/php-extras.ini
EXPOSE 80