How to change ownership of folder inside the container after build? I have this service in my docker-compose.yml
php-fpm:
container_name: php_app
restart: always
build:
context: .
dockerfile: ./docker/php-fpm/Dockerfile
volumes:
- ./src:/var/www/html
that take everything of the host folder src and add to /var/www/html:
FROM php:8.0.2-fpm-alpine
WORKDIR /var/www/html

RUN docker-php-ext-install pdo_mysql
RUN docker-php-ext-install mysqli
RUN apk add icu-dev

COPY docker/php-fpm/config/php.ini /usr/local/etc/php/

RUN apk add --update nodejs nodejs-npm
RUN npm install gulp-cli -g
RUN npm install

COPY src src/

CMD [&quot;php-fpm&quot;]

EXPOSE 9000

accessing the container using sudo docker exec -it php_app sh  and executing ls -la I have:
drwxrwxr-x    6 1001     1001          4096 May 12 15:54 writable
which must be owned by www-data, how can I set the ownership automatically when the builds complete?
you need to create the www-data user in the dockerfile eg
RUN addgroup -g 1000 www-data &amp;&amp; adduser -G www-data -g www-data -s /bin/sh -D www-data

RUN chown -R www-data:www-data /home/www-data &amp;&amp; \
    chown -R www-data:www-data /var/www