0

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 ["php-fpm"]

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?

1 Answer 1

1

you need to create the www-data user in the dockerfile eg

RUN addgroup -g 1000 www-data && adduser -G www-data -g www-data -s /bin/sh -D www-data

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.