0

I'm working with a dockerized symfony 4 application. when I tried to clear cache i received this error:

Failed to copy "/home/wwwroot/sf4/var/cache/dev/doctrine/orm/Proxies/__CG__AppEntityCountry.php" to "/home/wwwroot/sf4/var/cache/de~/doctrine/orm/Proxies/__CG__AppEntityCountry.php" because s ource file could not be opened for reading. My docker-compose.yml file :

version: '3'
services:
apache:
    build: .docker/apache
    container_name: sf4_apache
    ports:
    - 80:80
    volumes:
    - .docker/config/vhosts:/etc/apache2/sites-enabled
    - .:/home/wwwroot/sf4
    depends_on:
    - php

mysql:
    image: mysql:5.7
    command: "--default-authentication-plugin=mysql_native_password"
    volumes:
        - .docker/data/db:/var/lib/mysql
    environment:
        MYSQL_ROOT_PASSWORD: root
        MYSQL_DATABASE: e-electricity-v2
        MYSQL_USER: e-electricity-v2-user
        MYSQL_PASSWORD: E_elec@2018_v2

php:
    build: .docker/php
    container_name: sf4_php
    volumes:
    - .:/home/wwwroot/sf4
    - ./var/cache:/home/wwwroot/sf4/var/cache
    - ./var/log:/home/wwwroot/sf4/var/log
    environment:
    - maildev_host=sf4_maildev
    depends_on:
    - maildev
    - mysql

phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: sf4_phpmyadmin
    environment:
        PMA_HOST: mysql
        PMA_PORT: 3306
    ports:
    - 8080:80
    links:
    - mysql

maildev:
    image: djfarrelly/maildev
    container_name: sf4_maildev
    ports:
    - 8001:80

FROM php:7.2.3-fpm

##<romaricp>##
RUN apt-get update \
    && apt-get install -y --no-install-recommends vim curl debconf subversion git apt-transport-https apt-utils \
    build-essential locales acl mailutils wget nodejs zip unzip \
    gnupg gnupg1 gnupg2

RUN docker-php-ext-install pdo pdo_mysql

COPY php.ini /etc/php/7.2.3/php.ini
COPY php-fpm-pool.conf /etc/php/7.2.3/pool.d/www.conf

RUN curl -sSk https://getcomposer.org/installer | php -- --disable-tls && \
 mv composer.phar /usr/local/bin/composer

RUN wget --no-check-certificate https://phar.phpunit.de/phpunit-6.5.3.phar && \
    mv phpunit*.phar phpunit.phar && \
    chmod +x phpunit.phar && \
    mv phpunit.phar /usr/local/bin/phpunit

RUN echo "deb https://deb.nodesource.com/node_6.x jessie main" >> /etc/apt/sources.list.d/nodejs.list && \
 wget -nv -O -  https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - && \
 echo "deb-src https://deb.nodesource.com/node_6.x jessie main" >> /etc/apt/sources.list.d/nodejs.list && \
    apt-get update && \
 apt-get install -y --force-yes nodejs && \
 rm -f /etc/apt/sources.list.d/nodejs.list

RUN groupadd dev -g 999
RUN useradd dev -g dev -d /home/dev -m

RUN rm -rf /var/lib/apt/lists/*
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
    echo "fr_FR.UTF-8 UTF-8" >> /etc/locale.gen && \
    locale-gen

WORKDIR /home/wwwroot/
##</romaricp>##

EXPOSE 9000
CMD ["php-fpm"]
Cœur
  • 37,241
  • 25
  • 195
  • 267
Claude
  • 81
  • 1
  • 9
  • This looks like a problem with user permissions inside your php container. Could you also paste the content of your Dockerfile from `./docker/php`? – dbrumann Dec 18 '18 at 14:25
  • i edited the post and i added the dockerfile content – Claude Dec 18 '18 at 14:36
  • I assume that `groupadd` and `useradd` are responsible for your problems, as their gid/uid probably won't match with the permissions on your host system. I have seen many workarounds for this, e.g. passing in the host user's uid & gid as arguments to the docker-compose file. Depending on where you use this script the "easiest" workaround I would go for is removing both lines for now. In a production setup you will likely use COPY instead of mounting a shared volume, so leaving the permissions there would be fine. Maybe someone else comes up with a better solution. – dbrumann Dec 18 '18 at 14:54

0 Answers0