I am trying to set up a Symfony project using docker, but it always returns permissions related to permissions in the cache directory.
I tried everything and I can not find a solution. The problem is that the cache folder is always created with the owner "root", even if my server and user php-fpm are configured as www-data. Maybe due to php-cli user?
I tried: - setfacl: not working with docker - chown / chmod for www data: also not working. this may change the owner correctly at the beginning, but they give an error elsewhere.
docker-compose.yml
app:
build: .
command: "tail -f /dev/null" # keep the application container running
links:
- mysql
volumes:
- .:/var/www
nginx:
build: docker/nginx/
ports:
- 8090:80
links:
- php-fpm
volumes_from:
- app
php-fpm:
build: docker/fpm
ports:
- 9000:9000
volumes_from:
- app
mysql:
image: mysql:5.7
volumes:
- ./docker/data/mysql:/var/lib/mysql
Dockerfile of my application:
FROM php:5.6-cli
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y \
git \
vim \
curl \
php5-json \
php5-intl \
php5-mcrypt \
php5-mysql \
php5-apcu \
php5-gd
ADD /docker/fpm/php.ini /usr/local/etc/php/
RUN curl -sS https://getcomposer.org/installer | php
RUN mv composer.phar /usr/local/bin/composer
RUN usermod -u 1000 www-data
ADD . /var/www
WORKDIR /var/www
Php-fpm dockerfile
FROM php:5.6-fpm
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y \
php5-json \
php5-intl \
php5-mcrypt \
php5-mysql \
php5-apcu \
php5-gd
RUN apt-get install -y php5-xdebug
ADD xdebug.ini /usr/local/etc/php/conf.d/
ADD php.ini /usr/local/etc/php/
EXPOSE 9000
WORKDIR /var/www
CMD ["php-fpm"]
Docker nginx file
FROM nginx:latest
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y git vim
ADD nginx.conf /etc/nginx/
ADD symfony.conf /etc/nginx/sites-available/
RUN mkdir -p /etc/nginx/sites-enabled
RUN ln -s /etc/nginx/sites-available/symfony.conf /etc/nginx/sites-enabled/
RUN usermod -u 1000 www-data
EXPOSE 80
EXPOSE 443
ENTRYPOINT ["nginx"]
I have no ideas. Any suggestions? Thanks.